Tagged: datepicker, form
-
AuthorPosts
-
April 3, 2017 at 5:13 pm #771229
Hello Kriesi Support
is it possible to set the datepicker in your forms to only show Dates in the Future from today?
Right now one can select whatever date he wants but i want to limit this to dates in the future.Or as an alternative limit it to just 12 months into the future, starting from today .
Thanks und best regards
MatsApril 3, 2017 at 8:40 pm #771314Hi MatthiasKrebs!
Our date pickers are not so advanced to be honest but you can do with some custom coding
https://kriesi.at/support/topic/disable-specific-dates-in-datepickerthttpwww-kriesi-atsupporttopicdisable/Here are some exmaples, you can follow them, if you have issues, consider to hire a developer to help you with the modifications.
Thank you
Cheers!
BasilisApril 3, 2017 at 8:53 pm #771322hm i think the rule is set on class-form-generator.php since line 463ff
( it is in enfold – framework – php )maybe you can insert here from 494 the minDate and maxDate options
https://jqueryui.com/datepicker/#min-maxfrom about line 509:
changeMonth: true, changeYear: true, minDate: 0, maxDate: "+12m" }); });';
after ChangeYear i inserted those two parameters
minDate: 0 – means today on
maxDate i have set +12month
i deleted the year range parameteror look here: https://api.jqueryui.com/datepicker/#option-minDate
don’t know if there is a way to make it via child-theme hook
April 3, 2017 at 9:07 pm #771326April 5, 2017 at 8:06 am #772291Works like charm, thanks a lot @guenni007 (If you want to have a look: https://alpina-paragliding.ch/gleitschirm/tandemfluege/)
Now i am able to customize even more stuff i need, key question as always : which file to change and where to find it.
But for now: One step closer for going live…But how do i hook it into the child theme? Right now i’ve changed main theme and so i have lost update compatibility! Something i do not like much…
Thanks and many greetings
MatsApril 5, 2017 at 12:20 pm #772455overwrite the php you have inserted to your parent theme with original and try this here in child-theme functions.php
coming soon – seem to be a bit buggy :lol
no -sorry i managed it to insert those settings but on enfold then something mismatched.
maybe one mod could help here.- This reply was modified 7 years, 7 months ago by Guenni007.
April 7, 2017 at 3:03 pm #774018Hi,
Please copy unmodified enfold/framework/php/class-form-generator.php file and paste it inside enfold-child folder and find following at the top and remove it (please do not remove PHP opening tag)
if ( ! defined( 'AVIA_FW' ) ) exit( 'No direct script access allowed' );
and then add following code to Functions.php file of your child theme
require( 'class-form-generator.php' );
and then apply the changes on the file on your child theme
@Guenni007 Thanks for your help! :)Best regards,
YigitApril 7, 2017 at 3:39 pm #774037hm – i thought we can manage it via :
$.datepicker.setDefaults({ minDate: 0, maxDate: "+12m" })
but when i’m sucessful with that code inserted – some other things on enfold do not work correct. – And i don’t know realy why
April 7, 2017 at 4:19 pm #774058or – because it is an own action
add_action( 'wp_footer', 'helper_print_datepicker_script' );
that we can remove the action and set up a new one.
April 7, 2017 at 5:13 pm #774080could you please try to do this in functions.php of child-theme:
function my_datepicker_defaults() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery.datepicker.setDefaults({ minDate: 0, maxDate: "+12m" }); }); </script> <?php } add_action('wp_footer', 'my_datepicker_defaults', 20);
this seems to work on my test installation
April 7, 2017 at 5:20 pm #774083this gives you the opportunity to do it via if clauses :
(in this case only for page 3191function my_datepicker_defaults() { if( is_page(3191) ) { ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery.datepicker.setDefaults({ minDate: 0, maxDate: "+12m" }); }); </script> <?php } } add_action('wp_footer', 'my_datepicker_defaults', 20);
see it in action: not for this sites: https://webers-testseite.de/kokon/elements/contact-form/
but for that 3191 site: https://webers-testseite.de/kokon/flexbox/April 10, 2017 at 1:18 pm #775442April 11, 2017 at 9:22 am #775892@Guenni007
You sir are an outstanding genius. Thanks so much for your help and support. Awesome!
@Yigit
Thanks for your help too. Everythings fine nowGreetings
MatsApril 11, 2017 at 10:50 am #775932Hi,
Let us know if you have any other questions or issues :)
Best regards,
John Torvik -
AuthorPosts
- You must be logged in to reply to this topic.