Home › Forums › Calendar Products › Community Events › Follow up to Required Fields Error Messages
- This topic has 8 replies, 3 voices, and was last updated 10 years, 4 months ago by
Geoff.
-
AuthorPosts
-
October 30, 2015 at 5:07 pm #1020448
Sean
ParticipantFollowing up to this topic. After further testing, I found that when submitting an event, if the user selects a Saved Venue or Saved Organizer, the “square bracketed” fields are not recognized as having data (even though the saved venue/organizer does have data in those fields). Thus, the user is unable to submit the event. Advice?
Here’s the code we’re using in our functions file:
// TEC: Customize the List of Required Fields on // the Community Events Submit an Event Form add_filter( 'tribe_events_community_required_fields', 'my_community_required_fields', 10, 1 ); function my_community_required_fields( $fields ) { $fields = array( 'post_title', 'EventStartDate', 'EventStartHour', 'EventStartMinute', 'EventStartMeridian', 'tax_input', 'EventURL', 'organizer', 'venue', '_ecp_custom_2', ); return $fields; } // Require the organizer email (or other "square bracketed" // fields) by testing within the $_POST superglobal directly. add_filter( 'tribe_events_community_required_fields', 'tribe_community_required_fields_org_email', 10, 1 ); function tribe_community_required_fields_org_email( $fields ) { if ( isset( $_POST['organizer']['Email'] ) ) { $required_email = $_POST['organizer']['Email']; foreach( $required_email as $email) { if ( empty( $email ) ) $fields[] = 'Organizer Email'; } } return $fields; } add_filter( 'tribe_events_community_required_fields', 'tribe_community_required_fields_venue_city', 10, 1 ); function tribe_community_required_fields_venue_city( $fields ) { if ( empty( $_POST['venue']['Address'] ) ) $fields[] = 'Venue Address'; if ( empty( $_POST['venue']['City'] ) ) $fields[] = 'Venue City'; if ( empty( $_POST['venue']['State'] ) ) $fields[] = 'Venue State'; if ( empty( $_POST['venue']['Zip'] ) ) $fields[] = 'Venue Zip Code'; return $fields; }October 30, 2015 at 5:31 pm #1020450Sean
ParticipantAlso, when selecting an option for the Additional Field “Event Type” the following error is returned in the Additional fields meta box:
Warning: stripslashes() expects parameter 1 to be string, array given in /wp-content/plugins/the-events-calendar-community-events/src/Tribe/Event_Form.php on line 204
Obviously with that being a core file, it is unchanged on our end. Why would this be occurring and how can it be resolved?
Thank you,
KarlyOctober 30, 2015 at 6:00 pm #1020454Sean
ParticipantMight as well report a few other issues I discovered when further testing the Submit an Event form. These all occur when the required fields error message is returned after the user does not initially enter all required fields.
1. All recurrence rules entered are reset (rule changes back to “once” and user must re-enter all rules).
2. Data entered into any of the Organizer fields (Organizer Name, Organizer Email, etc) is erased.
3. For Additional Fields that are checkbox options, any selected options are erased upon the page refreshing and the required fields error messages being shown.
4. When editing an recurring event via the Community Events form, the message “Warning: You are editing a recurring event. All changes will be applied to the entire series.” is displayed at the top of the form. However, this leads to the custom error message that is set for the form to also be displayed. I assume this last item can be fixed by adding an additional conditional statement in the functions.php file to not return the custom error message when the page is initially displayed when the user starts to “edit” the recurring event?November 2, 2015 at 6:52 am #1020746Brook
ParticipantHowdy Karly,
Thank you very much for taking the time to clearly detail the problem and what modification you are using. I would love to help you with this.
I have done some investigating. Every area where a field clears upon submission is the result of a bug in our plugin:
All recurrence rules entered are reset (rule changes back to “once” and user must re-enter all rules).
Data entered into any of the Organizer fields (Organizer Name, Organizer Email, etc) is erased.
Warning: stripslashes() expects parameter 1 to be string, array given in /wp-content/plugins/the-events-calendar-community-events/src/Tribe/Event_Form.php on line 204
For Additional Fields that are checkbox options, any selected options are erased upon the page refreshing and the required fields error messages being shown.
As such they will require us to create an update to the plugin itself. We will likely need to fix this in version 4.0.x of the plugin, which will be due out in a few weeks.
The final issue you have reported:
When editing an recurring event via the Community Events form, the message “Warning: You are editing a recurring event. All changes will be applied to the entire series.” is displayed at the top of the form. However, this leads to the custom error message that is set for the form to also be displayed. I assume this last item can be fixed by adding an additional conditional statement in the functions.php file to not return the custom error message when the page is initially displayed when the user starts to “edit” the recurring event?
I actually can not reproduce this error with the code you shared. When I edit an event, the only error message that shows up initially is the recurrence series one which is expected behavior. Upon submit more errors may show if the required fields are empty.
However, to answer your question you can detect if this an edit event page by doing the following:
if ( strpos($_SERVER['REQUEST_URI'], '/events/community/edit/') === 0 ) { // You are editing an event }Thanks again for the report. Does my response make sense and fully answer your questions?
Cheers!
– Brook
November 2, 2015 at 12:43 pm #1020949Sean
ParticipantHi again Brook,
Thanks for your reply. Good to know that the fields being cleared upon submission is a bug with the plugin itself (as opposed to something on my end!). Hope that a fix can be released soon after 4.0 ships, but happy to hear it is on your “to-do” list 🙂
Regarding the last issue, I actually wasn’t referring to an individual error message that is shown when editing a recurring event. It’s just the custom message that appears above the error messages. So in my case, I see the following when editing a recurring event:
There was a problem submitting your event. The following fields are required:
Warning: You are editing a recurring event. All changes will be applied to the entire series.
This is the snippet that I’m using in my functions.php to customize the required fields error message and create the message that appears before any “XXX is required” error messages or the recurring event edit warning.
// Customize Required Fields Error Message function ce_custom_error_msg( $errors ) { // Don't filter if it is an 'update' or other type of message if ( $errors[0]['type'] != 'error' ) return $errors; $existing_errors = ''; $type = 'error'; if ( is_array( $errors ) ) { $existing_errors = $errors[0]['message']; $type = $errors[0]['type']; } // Set overall message by appending a heading to the front $errors[0] = array( 'type' => $type, 'message' => '<h5>There was a problem submitting your event. The following fields are required:</h5>' . $existing_errors );Wasn’t sure how or if it is possible to only have the heading that is appended to the front only appear when the form is submitted with errors (so it isn’t added when the “Warning: You are editing a recurring event…” is displayed).
November 2, 2015 at 8:03 pm #1021086Brook
ParticipantOh okay, I follow. Thanks for clarifying. In that case you could want to wrap the “There was a problem submitting your event…” with that code. Here is a modified version of it that fires when you are not editing an event:
if ( strpos($_SERVER['REQUEST_URI'], '/events/community/edit/') !== 0 ) { // You are not editing an event }That work?
Cheers!
– Brook
November 3, 2015 at 6:30 pm #1021517Sean
ParticipantBrook,
That works great. Thank you very much for helping with this!
Best,
KarlyNovember 3, 2015 at 11:39 pm #1021570Brook
ParticipantExcellent! Happy to hear it. Thanks for getting back, Karly.
– Brook
December 10, 2015 at 2:07 pm #1039166Geoff
MemberHey Karly,
Just jumping in to let you now that the patch for this issue is included in 4.0.1 and will be released shortly. Keep your eyes open for the update and please do let us know if any other issues pop up and we’d be happy to help. 🙂
Cheers!
Geoff -
AuthorPosts
- The topic ‘Follow up to Required Fields Error Messages’ is closed to new replies.
