cpx3 Posted March 23, 2024 Posted March 23, 2024 I have a (Formbuilder) form that contains two datefields, each of them with a datepicker. The first datefield should have today as the minimum date (no date selectable before today), the second one should have the date from field1 plus 1 day as a minimum. Any ideas how I could achieve that? Thanks!
ngrmm Posted March 23, 2024 Posted March 23, 2024 @cpx3 you could select the html5 native date field as your type and choos today as your default value. Your minimum values can be set via a hook $wire->addHookBefore('FormBuilderProcessor::renderReady', function($event) { $form = $event->arguments(0); if($form->name != 'your-form-name') return; $inputfield_1 = $form->getChildByName('your_date_field_1'); $inputfield_2 = $form->getChildByName('your_date_field_2'); if($inputfield_1) $inputfield_1->attr('min', date('Y-m-d')); if($inputfield_2) $inputfield_2->attr('min', date('Y-m-d', strtotime(' +1 day'))); });
cpx3 Posted March 24, 2024 Author Posted March 24, 2024 First, a million thanks. The only thing is that neither this works, as the HTML datepicker seems to ignore the value and shows all dates. I wonder seriously why Ryan decided to cut this function from the datepicker (at least with the paid FormBuilder module), as with Javascript it would work...
ngrmm Posted March 24, 2024 Posted March 24, 2024 @cpx3 please triple check everything. It works for me. Which embed version are you using?
cpx3 Posted March 24, 2024 Author Posted March 24, 2024 I use method D because there is no other way to style the select elements. Ok, I will check everything again!
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now