Skip Navigation

[Resolved] Custom Field Not Saving

This thread is resolved. Here is a description of the problem and solution.

Problem: I have a custom field in a Form that is not saving. The field is surrounded by a wpv-conditional statement.

Solution: Instead of wrapping the field in a conditional, try using the conditional to toggle the display of a parent container on or off using CSS. Conditionals around field shortcodes can be problematic.

This support ticket is created 6 years, 4 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 6 replies, has 2 voices.

Last updated by aaronM-9 6 years, 4 months ago.

Assisted by: Christian Cox.

Author
Posts
#922073

Hi,

I've recently added a field to a Toolset form called "conversation-email-broadcast" but it's not saving when the form submits (all other custom fields are saving). I am getting the following error message:

PHP Warning: array_key_exists() expects parameter 2 to be array, boolean given in .../plugins/wp-views/embedded/inc/wpv-shortcodes.php on line 3229

Can you give me some insight into what this error message could indicate? There are also two hooks at play. For details on one, please refer to the following ticket: https://toolset.com/forums/topic/difficulty-storing-related-post/

For the other hook, it is set to perform some function if the value of the wpcf-conversation-email-broadcast field is "Yes" but it doesn't do anything because the field is not even stored to the WordPress database.

Thanks for any assistance.

- Aaron

#922209

Could you take a screenshot of this field and all its options in the field editor screen? Then copy and paste here any code used to insert the field in the Form. I'll review both and try to determine what's happening.

#922596
temp2.jpg
temp1.jpg
temp.jpg

Hi Christian,

Attached are screenshots of the field settings, the form as displayed on the front-end, and all meta data after submission. Below is the form code:

[wpv-conditional if="( '[wpv-attribute name="admin"]' eq 'true' )"]
      <div class="form-group">
        <label>Admin Options</label>
        [cred_field field='conversation-email-broadcast' value='' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap']
      </div>
[/wpv-conditional]
#922681

Try removing the value and urlparam attributes from this field shortcode, then test again. If that does not work, remove the conditional around this field shortcode and test again. Let me know the results of those two tests.

#922976

Hi Christian,

Removing the two attributes had no effect but removing the conditional shortcode caused it to start working. Any ideas on why that conditional shortcode would be causing the issue? I need to be able to make that field conditional. The way the views are nested checks to see if the user is RSVP'd to the event and whether or not they are tagged as an admin of the event. That value gets passed in a view attribute. Maybe there's an alternative way to do it? I know these attributes can be used in forms because I sometimes use them to set default values in the forms. Strange that it wouldn't work in the conditional shortcode.

- Aaron

#923169

In general, I don't recommend using conditionals around Forms field shortcodes. Using conditionals to toggle a "hidden" CSS class would be less likely to cause problems with the field display engine. Would you be able to do something like this instead:

[wpv-conditional if="( '[wpv-attribute name="admin"]' eq 'true' )"]
  <div class="show">
[/wpv-conditional]
[wpv-conditional if="( '[wpv-attribute name="admin"]' eq 'true' )" evaluate="false"]
  <div class="hide">
[/wpv-conditional]

<label>Admin Options</label>
        [cred_field field='conversation-email-broadcast' value='' urlparam='' select_text='--- not set ---' class='form-control' output='bootstrap']
      </div>
#923225

Great idea. That did the trick. Thanks again!

- Aaron