Hello,
I have a form with this field
[cred_field field='observations-concernant-la-confirmation' post='commande' value='' urlparam='' class='form-control' output='bootstrap']
I want it to update 2 custom fields : wpcf-observations-concernant-la-confirmation and wpcf-observations-concernant-l-annulation.
For that, I made a function based on cred save data api with this line:
update_post_meta($post_id, 'wpcf-observations-concernant-l-annulation', $_POST['observations-concernant-la-confirmation'], true);
But when I submit the form, the field specified in the function doesn't update, and I got this error logged :
[13-Aug-2017 15:34:00 UTC] PHP Notice: Undefined index: observations-concernant-la-confirmation in /home/netispgaja/adage/wp-content/themes/toolset-starter-child/functions.php on line 529
I don't see what I'm missing here ; is it a problem with the function ?
Thank you.
The error says that $_POST['observations-concernant-la-confirmation'] is undefined because the form isn't submitting this information for some reason. The reason could be:
- The field is named something else. You can check this by examining the form's source HTML. You should find an input or select field with the name 'observations-concernant-la-confirmation'. If you do not, you must change your code to match the input name:
$_POST['your-field-name']
- If the field is named correctly and the value is defined, then check to see if the 'js-wpv-filter-trigger' is applied to the input. If not, add that class. This is likely the problem if you add your own custom input elements to the filter controls.
- If the field is named correctly and the value is defined, and the 'js-wpv-filter-trigger' class is applied to this input field, we'll need to take a closer look. I'll enable private reply fields.
You can add a CSS class in the "class" attribute, after 'form-control':
[cred_field field='observations-concernant-la-confirmation' post='commande' value='' urlparam='' class='form-control js-wpv-filter-trigger' output='bootstrap']
This is documented in the CRED shortcodes doc:
https://toolset.com/documentation/user-guides/cred-shortcodes/#cred_field
OK this seems odd... I used another way.
Thank you.