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

Slack Signup
Newsletter Optin
Help Desk

Keep the default value

Labels

This Discussion is public

Notifications

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.

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/

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.

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.