The Community forums are being phased out in favor of a new Slack group.
Add your email address below to get an invitation to join the community slack group
Keep the default value
Hello,
I use this code for keeping the default value, but it seems i still keep once user input the value.
I need some custom code not keep the default value when a user input the value.
function ff_keep_default_value( $errors, $posted_field, $posted_value ) { $fields = array( 166, 168, 169 ); //change 166, 168, 169 to the IDs of the fields whose defaults you want to keep. Include as many fields as you want. if ( in_array( $posted_field->id, $fields ) ) { $field_id = $posted_field->id; $field = FrmField::getOne( $field_id ); $default_value = ""; if ( $field && isset( $field->default_value ) ) { $default_value = $field->default_value; } $default_value = do_shortcode( $default_value ); $_POST['item_meta'][ $field_id ] = $default_value; } return $errors; }
Please help!
Thanks.
March 23, 2018 at 6:21 am
You don't need custom code. There's a button to the right of the field for clearing the default value when a users enters input. Just click the button. See this: https://formidableforms.com/knowledgebase/using-dynamic-default-values-in-fields/
March 23, 2018 at 1:40 pm
Hi,
You are right, but It won't work with entries. The default values are not saved with the form submission.
That is why I used the code.
March 23, 2018 at 1:50 pm
That's not correct. Default entries are absolutely saved with the form. That's the entire purpose of a default entry. I just tested this in my development environment and saving default entries works perfectly. You have to make certain the the button to the left of the clear default entry button shows the checkmark and not the x.
Discussion closed.