Cakephp form date value

Cakephp form date value

By: sergsa Date: 10.06.2017
cakephp form date value

This has been bugging me for a while now. I would like to use a Javascript datetimepicker, instead of the default set of select boxes that the CakePHP Formhelper generates. The easy solution would seem to be:. But this introduces some other problems as Cake will then convert the values into the locale format. I would also prefer a solution that worked from a general perspective, so I looked into changing the template for the datetime input:.

This, however is as close as I've gotten.

php - CakePHP: Date field with default values - Stack Overflow

What happens is that the Formhelper outputs a nice text input, with an empty name attribute, which defeats the purpose. I assume this is because the datetimeinput is basically wired to output the select fields, and is thus confused by my approach here. This will display a text field, add my datepicker-input class to the field.

Show default date value in y-m-d format so that date picker can instantly read the current date.

By posting your answer, you agree to the privacy policy and terms of service. Stack Overflow Questions Developer Jobs Documentation beta Tags Users.

cakephp form date value

Sign up or log in to customize your list. Tour Start here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this does jennamarbles make money on youtube About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us. Log In Sign Up.

Join the Stack Overflow Community. Stack Overflow is a community of 7. Join them; it only takes a minute: The easy solution would seem to be: I would also prefer a solution that worked from a general perspective, so I looked cakephp form date value changing the template for the datetime input: But what would be the right way to do it?

php - CakePHP: How to change default value of Date input - Stack Overflow

Jonas Kvist Jensen 7 8. What's the problem with the localized format? Usually that's what you want to show your users instead of this generic YYYY-MM-DD SQL format. I think you are right.

php - Getting CakePHP HtmlHelper to generate a "date" input - Stack Overflow

Would have been nice to be able to do a more streamlined version, but what you say could work. Can the localized format be customized to a pattern somewhere? Actually I still can't make this happen. The input will not validate when using a text input, as Cake uses a time object that seems incompatible with the straight text.

If you validate using the internal date validation, then you need to make sure that it uses the same pattern as your input. JonasKvistJensen did you figure it out? I am also using a datetimepicker github. I have temporarily solved this problem by this line: This way it also save this data in database without any further issue. I used jQuery datepicker for the job. Sign up or log in StackExchange. Sign up using Facebook. Sign up using Email and Password. Post as a guest Name.

Stack Overflow works best with JavaScript enabled. MathOverflow Mathematics Cross Validated stats Theoretical Computer Science Physics Chemistry Biology Computer Science Philosophy more 3. Meta Stack Exchange Stack Apps Area 51 Stack Overflow Talent.

Rating 4,2 stars - 282 reviews
inserted by FC2 system