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
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.
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]
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.
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
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>
Great idea. That did the trick. Thanks again!
- Aaron