Tagged: datepicker, Reservation form
-
AuthorPosts
-
June 12, 2017 at 7:14 am #806748
Hi for my site’s reservation form, please can I ask how I can disable just a single specific date for selection? On the forums I’ve managed to find some semi solutions, but it was to disable a day of the week throughout the year,
I’m hoping to disable just a specific date such as 18-06-2017.
Thank you!
June 13, 2017 at 3:10 pm #807505Hey Jon,
Please use a child theme – http://kriesi.at/documentation/enfold/using-a-child-theme/ then 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' );
Then open class-form-generator.php file in your child theme and find
echo 'jQuery(document).ready(function(){ jQuery(".avia_datepicker").datepicker({
then add following right below that line
beforeShowDay: function(date){ var string = jQuery.datepicker.formatDate('2017-06-18', date); return [$.inArray(string, array) == -1]; }
Best regards,
YigitJune 13, 2017 at 5:19 pm #807580Thanks very much for your kind help, Yigit!
Unfortunately, I now have an error message when I added in the above line.Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in /home/thaivill/public_html/wp-content/themes/enfold-child/class-form-generator.php on line 493
I’ve attached my php file for your kind reference. Is it because it’s been modified from before? Here’s the current line of code from that section
echo ‘jQuery(document).ready(function(){ jQuery(“.avia_datepicker”).datepicker({
minDate: 1,
beforeShow: function(input, inst) {
jQuery(“#ui-datepicker-div”).addClass(this.id);
inst.dpDiv.addClass(“avia-datepicker-div”);
},
showButtonPanel: true,Not quite sure where I went wrong there.
June 14, 2017 at 3:04 pm #808036Hi,
Please replace the content of class-form-generator.php file on your child theme with this one – https://pastebin.com/iHSatnc4
Best regards,
YigitJune 14, 2017 at 4:52 pm #808086Hey thanks, Yigit, I truly appreciate your help as always!
After doing so, I’m getting the following error:Parse error: syntax error, unexpected T_LNUMBER, expecting ‘,’ or ‘;’ in /home/thaivill/public_html/wp-content/themes/enfold-child/class-form-generator.php on line 498
I’ve attached my previous and current classform generator php file. Not sure why I’m getting the error for the life of me. :(
June 14, 2017 at 5:00 pm #808087Hey!
Can you please post FTP logins here privately and let us know the exact date you would like to disable, in case it is not 2017-06-18? :)
Cheers!
YigitJune 14, 2017 at 6:26 pm #808142on my Enfold the date is set to DD/MM/YY why can we use here the date in that form: 2017-06-18
you see the excluded days in the form day/month/year – month without a leading Zero
see solution down under :lol:
- This reply was modified 7 years, 5 months ago by Guenni007.
June 14, 2017 at 7:39 pm #808175by the way – here we can also set start and end time as well:
i had to make two functions of it because the one must load before helper datepicker starts:
and think of the month without leading zero !
function exclude_datepicker_dates() { ?> <script type="text/javascript"> var unavailableDates = ["17/12/2017", "12/12/2017", "18/6/2017"]; function unavailable(date) { dmy = date.getDate() + "/" + (date.getMonth() + 1) + "/" + date.getFullYear(); if (jQuery.inArray(dmy, unavailableDates) == -1) { return [true, ""]; } else { return [false, "", "Unavailable"]; } } </script> <?php } add_action('wp_footer', 'exclude_datepicker_dates', 10); function my_datepicker_defaults() { ?> <script type="text/javascript"> jQuery(document).ready(function(){ jQuery.datepicker.setDefaults({ beforeShowDay: unavailable, minDate: 0, maxDate: "+12m" }); }); </script> <?php } add_action('wp_footer', 'my_datepicker_defaults', 20);
.ui-datepicker td[title="Unavailable"] { background: rgba(120, 255, 180, 0.3); }
June 14, 2017 at 7:46 pm #808177checked here: https://webers-testseite.de/8-columns/
June 14, 2017 at 8:07 pm #808188new solution above . Only for functions.php child-theme nothing to copy or replace.
- This reply was modified 7 years, 5 months ago by Guenni007.
June 15, 2017 at 6:44 am #808410June 15, 2017 at 11:50 am #808528@guenni007, I can’t tell you how much I appreciate your awesome help! It’s one of the reasons why I love this theme so much, because of awesome ppl like you on this forum and on the Facebook Enfold Users page. Thank you from the bottom of my heart for taking the time to help. You are putting good out into this world! Thank you, thank you, thank you!
And also thank you to Yigit, Rikard and Enfold team for always providing the best wp support in the market!
- This reply was modified 7 years, 5 months ago by jasksks.
June 15, 2017 at 5:53 pm #808647Thanks – but the other way will work too.
But i like those snippets in functions.php because i don’t like to think of it when parent theme was updating, and having that bad feeling there might be changings on those edited files in child-theme folder.June 15, 2017 at 6:00 pm #808650Hi!
We’re glad that everyone was able to help out. :)
Do you still need further help with this topic, or can we close this thread?
Cheers!
SarahJune 16, 2017 at 4:42 pm #808996Hi Sarah, yes please do. Thank you very much!
June 17, 2017 at 8:08 am #809222Great!
For your information, you can take a look at Enfold documentation here – http://kriesi.at/documentation/enfold/
And if there are features that you wish Enfold had, you can request them and vote the requested ones here – https://kriesi.at/support/enfold-feature-requests/
For any other questions or issues, feel free to post them here on the forum and we will gladly try to help you.
Thank you for using Enfold.
Cheers!
Sarah -
AuthorPosts
- The topic ‘Disable single date datepicker’ is closed to new replies.