I am using Grails 4. My book domain has a date field. I use <f:all bean="book"/> in my edit view to display the input fields. The Fields plugin displays 3 dropdown boxes with the day, month, and year in the html for the date field in the book.
Would you teach me how to display a Datepicker instead of popping up 3 dropdown boxes please?
Thanks!
My bad. I just review the bootstrap document. Bootstrap does not have any native datepicker. I should ask how to replace the grails datepicker with the jquery ui datepicker.
Related
I am using grails datepicker in my form to generate date field
<g:datePicker name="published"></g:datePicker>
It generates the field in multi fields format as shown below.
I need the format as shown below. I was wondering whether there is a way to customize the datepicker so that the following multi fields format can be achieved. I couldn't find customization in the docs of datepicker.
The grails version i am using is 4.0.10. I appreciate any guide. Thanks!
I asked your same question before. This is not exactly what you want. This is what I did in my project. Hope you can make the changes that fit yours.
You need to override the Field plugin template and manually process the textboxes that are being POST back to your controller.
The document is in this page.
https://grails3-plugins.github.io/fields/snapshot/guide/customizingFieldRendering.html
You need to create a folder structure in the Views folder that matches your variable (either by name or by type).
In my case, I want to override the HTML whenever I have a Date variable shown on any of my views. So, I add these folders and this gsp file in my project path.
views/_fields/date/_wrapper.gsp
These folder structure says that whenever I have a Date field in any of my domain classes, it will use my HTML instead.
This is the HTML in my _wrapper.gsp file. I have a textbox called datepicker.
<input type="text" name="datepicker" id="datepicker" value="<g:formatDate date="${value}" format="MM/dd/yyyy"/>"></div>
I am using the datepicker from jquery-ui. So, I also add this javascript to my view.
$( function() {
$( "#datepicker" ).datepicker();
} );
After these, where ever the Field plugin that sees a Date field, it will pop up the jquery-ui datepicker when I click the textbox.
I have jQuery datepicker on a page that allows manual date entry.How to check the format and validation of date in the jQuery UI Datepicker.For example,input 20030230,and it will remind me of the incorrect date.
thanks for your help.
I' have 2 text fields 1st one for giving date from and the other one for date to, what i want is while i'm selecting date from using 'calendar:datePicker' the dates before current date must be disabled and if i have selected a date 1/6/2014 in 1st text field, when i select the date to from the 2nd one the dates before 1/6/2014 must be disabled how can i achive this..?
From<calendar:datePicker name="datefrom" years="${2014..2017}" value="${new Date()}" defaultValue="${new Date()}"/>
To<calendar:datePicker name="dateto" years="${2014..2017}" value="${new Date()}" defaultValue="${new Date()}"/>
That looks like an old plugin and it might not have the option that you need.
Use jQuery UI instead: http://jqueryui.com/datepicker/#date-range
jQuery UI has a grails plugin as well. http://grails.org/plugin/jquery-ui
I'm creating a form in which there will be a select box for day, month and year to store the date of birth of a person? I'm using devise and going to customize it. Thanks in advance.
You could use jQuery UI Datepicker:
http://jqueryui.com/datepicker/
There are plenty of other Datepickers around, just google it and find what is best for your stack. If you are using Twitter Bootstrap, here is something:
http://www.eyecon.ro/bootstrap-datepicker/
You can use the built-in date_select helper. Or you could use jquery datepicker
I have a Symfony 2.0 app.
It has a datetime field on an entity, and a datetime field on a form.
How can I have the date part of that form render with a jQuery UI date picker instead of the 3 select boxes?
Thanks,
EDIT
This is what I have so far:
$builder->add('start_at', 'datetime',array('date_widget' => 'single_text'));
This puts a text box on the page for the date then 2 select boxes for the time, and you can easily add a jQuery UI on top of that!
The problem is the Symfony datetime field only accepts input in the format "Aug 29, 2012". If the user types in "Aug 29 2012" or "29 Aug 2012" it refuses to validate.
So anyone who can fix that problem or suggest an entirely different working approach would be much appreciated.
I ended up using this code
$builder->add('start_at', 'datetime' ,array(
'date_widget'=> 'single_text',
'date_format'=>'d/M/y',
....
));
then putting jQuery UI on top of it, and just dealing with the fact that it only accepts input in one format only.
Take a look at this bundle. It provides several extra form types, including a jquery date form field:
https://github.com/genemu/GenemuFormBundle