- This topic has 5 replies, 4 voices, and was last updated 6 years, 11 months ago by
Steve.
-
AuthorPosts
-
-
January 31, 2015 at 4:25 am #3253
hirschbratMemberHello,
is there any hook that I can use to validate multiple custom fields at the same time?
E.g. I have a meta-box with three dates and want to validate the dates as follows:
date1 < date2 < date3
AND date2-date1 > 5 days
AND date3-date2 > 5 days -
January 31, 2015 at 5:07 am #3254
KevinKeymasterActually yes. Can you post your meta-box code? This way we can show you a relevant example.
Thanks,
Kevin
-
January 31, 2015 at 5:22 am #3255
hirschbratMemberHello Kevin,
this is my meta-box code. I want to validate the three fields fvb_shipping_date, fvb_event_date and fvb_return_date.
/* Title: Termine Description: Bestellte Produkte Post Type: fvb_order Capability: manage_options Context: side Priority: low Order: 1 Locked: false Collapse: false Meta box: true */ piklist('field', array( 'type' => 'datepicker' ,'field' => 'fvb_event_date' ,'label' => __('Veranstaltungsdatum', 'fvb_de') ,'options' => array( 'dateFormat' => 'yy-mm-dd' ,'firstDay' => '1' ,'minDate' => '0' ) ,'required' => true ,'on_post_status' => array( 'value' => 'reserved--closed' ) )); piklist('field', array( 'type' => 'number' ,'field' => 'fvb_event_period' ,'label' => __('Dauer', 'fvb_de') ,'description' => 'Tag(e)' ,'value' => 1 ,'on_post_status' => array( 'value' => 'reserved--closed' ) ,'validate' => array( array( 'type' => 'limit' ,'options' => array( 'min' => 1 ) ,'message' => 'Min 1 day.' ) ) )); piklist('field', array( 'type' => 'datepicker' ,'field' => 'fvb_shipping_date' ,'label' => __('Versand', 'fvb_de') ,'options' => array( 'dateFormat' => 'yy-mm-dd' ,'firstDay' => '1' ,'minDate' => '0' ) ,'required' => true ,'on_post_status' => array( 'value' => 'reserved--closed' ) )); piklist('field', array( 'type' => 'datepicker' ,'field' => 'fvb_return_date' ,'label' => __('Retour', 'fvb_de') ,'options' => array( 'dateFormat' => 'yy-mm-dd' ,'firstDay' => '1' ,'minDate' => '0' ) ,'required' => true ,'on_post_status' => array( 'value' => 'reserved--closed' ) )); -
February 2, 2015 at 8:09 pm #3263
KevinKeymaster@hirschbrat-
I spoke a little too soon, but not by much. We are very close to our next release and this version has a few upgrades to validation allowing you to inspect other fields in your callback. Email us at [email protected] and we will send you a snippet with a version of the beta this week.
Thanks,
Kevin
-
February 3, 2015 at 4:00 pm #3269
JasonKeymasterGreetings! Like Kevin said, in the next version you can view all the fields and validate accordingly. Presently, it’s possible to do this if multiple fields belong to a single group. For an example of this check out the ‘date-range’ validation in PiklistHelper: https://github.com/JasonTheAdams/PiklistHelper/blob/master/PiklistHelper.php#L231
-
February 23, 2015 at 11:30 pm #3350
SteveKeymaster@hirschbrat– The beta just got emailed to you. Let us know if you still have issues.
-
-
AuthorPosts
- You must be logged in to reply to this topic.