cf_custom_fields_populate_form_edit

Prepared from data for edit post.

Description

(array) cf_custom_fields_populate_form_edit( (array) $data, (array) $form, $entry_id ); 

Returns (array)

Parameters (3)

0. $data (array)
Form data.
1. $form (array)
Form config.
2. $entry_id
The entry id.

Usage

  1. if ( !function_exists( 'cf_custom_fields_populate_form_edit' ) ) { 
  2. require_once ABSPATH . PLUGINDIR . 'caldera-custom-fields/includes/to-post-type.php'; 
  3.  
  4. // Form data. 
  5. $data = array(); 
  6.  
  7. // Form config. 
  8. $form = array(); 
  9.  
  10. // The entry id. 
  11. $entry_id = null; 
  12.  
  13. // NOTICE! Understand what this does before running. 
  14. $result = cf_custom_fields_populate_form_edit($data, $form, $entry_id); 
  15.  

Defined (1)

The function is defined in the following location(s).

/includes/to-post-type.php  
  1. function cf_custom_fields_populate_form_edit( $data, $form, $entry_id ) { 
  2.  
  3. $processors = Caldera_Forms::get_processor_by_type( 'post_type', $form ); 
  4. if( !empty( $processors ) ) { 
  5. foreach( $processors as $processor ) { 
  6. if( !empty( $processor['config']['ID'] ) ) { 
  7. // ooo ID!!! 
  8. $ID = Caldera_Forms::do_magic_tags( $processor['config']['ID'], $entry_id ); 
  9. if( !empty( $ID ) ) { 
  10. $post = get_post( $ID ); 
  11. if( empty( $post ) ) { 
  12. return $data; 
  13.  
  14. $data[ $processor['config']['post_title'] ] = $post->post_title; 
  15. $data[ $processor['config']['post_content'] ] = $post->post_content; 
  16. foreach( $form['fields'] as $field_id => $field ) { 
  17. if( $post->{$field['slug']} ) { 
  18. $data[ $field_id ] = $post->{$field['slug']}; 
  19. return $data;