I give a look to daterange, I am not sure how it can be integrate without
yout to create your own piece of js code to handle the splitting of the 2
dates... daterangespicker seems to requires you to use a single field to
store the information... So you have 2 options, you create a single field
in your models/app and you drop the init js daterangepicker over it and you
get the validation perform only the daterangepicker plugin, or you createa
custom piece of js or python code to handle the input into a single html
input field that you on validation split into 2 fields before insert the
data into your database for convenience... It you take this path you will
have also to restore merge the 2 fields piece of data from the backend to
the plugin... You have many ways of doing it as mention with Javascript or
python... It depends of your expertise and your needs I guess...

I would suggest you a easier approach... Not use the daterangepicker plugin
and use 2 differents fields instead of start and end date... Both field
will validate independantly, but you can write a custom web2py validator
make sure a certain logic applys for instance that end date can't be before
the start date and that kind of stuff... Or you can even just leave that to
the end user to not make such dummy error...

If you want to create integration piece of code to split your single input
into 2 field in the backend you may consider hiding your field from
javascript, so web2py consider your field legetimate, has form doesn't
consider hidden field I think. So you can unhide your field just before the
form is sumbit...

With SQLFORM.factory() you can pas INPUT() or Field() if I recall... So you
can create INPUT(, _id='ID') which was your original question...

Good luck

Richard

On Thu, Jul 6, 2017 at 4:25 PM, backseat <kac...@gmail.com> wrote:

> You're right, of course.I, too, get frustrated by people asking the wrong
> question, and now I'm doing it...
>
> I have a form that requires a 'from_date' and a 'to_date', which is
> currently implemented using two fields. I like the idea of using the
> 'daterangepicker' tool, particularly the predefined date ranges (
> http://www.daterangepicker.com/#ex4). Within the js that implements the
> predefined ranges, it's relatively simple to update two hidden fields (my
> from_date and to_date) without worrying about the display format in the
> single daterangepicker text box. However, I think it might be easier just
> to parse the daterangepicker box anyway.
>
> Thanks for the pointer.
>
> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to web2py+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to