I am trying to: Create a search view, which filters by date. (The date field is defined in my custom fieldgroup.) The default value of the field should be TODAY(). I've set the "type of control" field in the field settings to "datepicker" instead of "As defined" in order to be able to add the default value. After that change the search doesn't seem to use my date value anymore. I've tried to set the "Compare value as" field to different values including string, date, number, datetime, etc. Norhing changed.
Link to a page where the issue can be seen: ultranaptar.hu
I expected to see: "Runpunch" event should not appear, becouse it is in the past.
Instead, I got: I can see the Rununch event.
Hi there,
The default value is not supported in the date picker in the Toolset Form.\\You can add the Javascript code below to the form to force the current date:
https://toolset.com/forums/topic/in-form-default-a-date-picker-to-today-60-days/#post-1294417
Thanks.
Hi Christopher,
thank you very much for your reply.
I've added a JS code based on the support ticket you've sent. I'm pretty sure I mismatch the syntax, as I'm not experinced in JS (or any) coding. I've tried several versions, still no result, the default value doesn't appear. Can you check my code, plese?
Thanks,
Gabor
jQuery(window).load(
function() {
var currentDate = new Date();
id = jQuery('input[name="wpcf-esemeny-idopontja[display-only]"').attr('id');
jQuery( "#"+id ).datepicker("option","setDate",currentDate);
}
);
Hi there,
I think the code is correct but I can also check if you give me the URL of the page that you have the form and the datepciker.
So basically you want to have the date picket input box show the today date correct?
Hi Christopher,
exactly. I want to set the first datepciker input field (marked with 'Kezdődátum' label) for the actual date. The field is on the opening page of hidden link
Thanks!
Hi there,
Ok, so the point on your website is something else.
You want to have the start date and then the search result selected according to that date.
That needs a lot of custom coding.
I suggest that you check this ticket for more information:
https://toolset.com/forums/topic/set-datepicker-to-today-by-default-and-enabled-on-initial-page-load/#post-484523
Check the ticket from the top to know why the code is suggested and you need to use something like that with your field name and view ID which you used.
To know what is your View ID, you need to turn on the legacy mode:
- Go to "Toolset > Settings > General".
- Find the "Editing experience" section.
- Check the "Show both the legacy and Blocks interface and let me choose which to use for each item I build" checkbox.
- Reload the browser page.
- Go to the newly added "Toolset > Views" menu.
- There you will be able to see the view ID before the view name.
For more information:
https://toolset.com/course-lesson/enabling-legacy-version-of-toolset-views/
Thanks.