Skip Navigation

[Resolved] Error while submitting a form

This support ticket is created 7 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 3 replies, has 2 voices.

Last updated by romanB-3 7 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#559325

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.

#559381

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.

#559564

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

#559627

OK this seems odd... I used another way.
Thank you.