Search

Dear All,

I have a section which has a date field, which currently only seems to accept the format yyyy-mm-dd. I would like to have users insert the date in the most comfortable way, without sticking to such a strict rule. Is there any way I can convert the user input before it is sent to the back-end?

Thank you for your help!

My solution has been using html5 inputs (date, time, and datetime) with a javascript library or plugin such as mobiscroll.

The user input can be converted at the backend before it is saved, by means of a custom event. In brief, this is done by creating a section event (Blueprints -> Events), attaching it to the required page, and then modifying the PHP file that has been created.

'finferflu', I can give a longer explanation if you want one.

@thebestsophist: Thanks, I had already thought about that, however this is not a completely fail proof solution, since it's client-based, and users may have JavaScript disabled. Thanks for your input anyway :)

@Petertron: Yes, that's exactly what I was looking for, but I've never tinkered with the code behind Symphony. A longer explanation would be greatly appreciated. Thanks!

Do you want the date to be input in one field, or to use separate fields for day, month and year which would be saved as one field?

All in one input (the current year should be implicit, unless the date is close to the year after, but that's another story I guess).

What I am wondering now is how you can have the problem of your date field only accepting the format yyyy-mm-dd. When a date is saved it is parsed and converted first, so something like "7th July 2013" will work. The year can even be left out and it will be inserted.

Yes, you're right... I opened this topic because I've had trouble submitting a valid date. I have tested it again now, and it works indeed. I will do some more testing and see if I can catch it again.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details