Skip to content

Instantly share code, notes, and snippets.

@Shelob9
Created June 30, 2017 01:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Shelob9/cb9182fbbee37e0445d3af566aec5105 to your computer and use it in GitHub Desktop.
Save Shelob9/cb9182fbbee37e0445d3af566aec5105 to your computer and use it in GitHub Desktop.
Code examples for using Caldera_Forms_Entry_Field::insert() and Caldera_Forms_Entry_Update::update_field() to add and update field values of an entry programatically
<?php
/**
* Add a Caldera Forms Field value programatically
*/
//IMPORTANT, Change your field and form IDs.
$field = Caldera_Forms_Field_Util::get_field( 'fld4223', Caldera_Forms_Forms::get_form( 'cf1345' ) );
$field_item = array(
'entry_id' => 42,
'field_id' => $field[ 'ID' ],
'slug' => $field[ 'slug' ],
'value' => 'Some Value'
);
//insert new field value
$field = Caldera_Forms_Entry_Field::insert( $field_item, true );
/**
* Update a Caldera Forms Field value programatically
*/
//change field value
$field->set_value( 'Some other value' );
//save change
Caldera_Forms_Entry_Update::update_field( $field );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment