add filter to append extra fields during fields render
-
Hello,
First, thank you for this plugin , it’s been very helpful.
One feature I find missing is the ability to customize form field values before they are rendered in the admin detail view.
Use case example:
Suppose we have a form field that stores apost_id. During render, we may want to append another field showing the corresponding post title, e.g.post_title: get_the_title( $id ).Currently, this requires editing the plugin core. For example, in
inc/admin-form-details.php46:$form_data = unserialize( $results[0]->form_value );
// Adding a filterable variable so $form_data remains untouched
$fields = apply_filters( 'cfdb7_form_fields', $form_data, $this->form_post_id );
// Using $fields variable to render fields
foreach ( $fields as $key => $data ):And in
functions.php, we could then extend the data safely:add_filter( 'cfdb7_form_fields', function( $data, $form_post_id ) {
if ( $form_post_id !== 300 ) return $data;
$data['test_field'] = 'test value';
return $data;
}, 10, 2 );Thank you!
The topic ‘add filter to append extra fields during fields render’ is closed to new replies.