Keyword

Validation in the frontend submit form

  • Daniel
  • Daniel's Avatar Topic Author
  • Offline
  • New Member
More
8 years 10 months ago #145700 by Daniel
Hi guys,

I hope you can help or guide me here since I'm about to jump out of a window.

My site uses K2 as the foundation to create an event's site. In other words, K2 items represent events, and these events are user generated from the frontend. With a nice template and a couple of cool extensions everything was looking great, so I went live in beta testing mode and invited some users to submit their events.

The majority of them (but a few don't) are having the same issue when they click save in the frontend K2 submit item form:

DateTime::__construct(): Failed to parse time string (2015-18-8 00:00:00) at position 6 (8): Unexpected character

or

DateTime::__construct(): Failed to parse time string (undefined-undefined-15. März 2016) at position 0 (u): The timezone could not be found in the database


As you can imagine events rely heavily on dates, start date, end date, registration start date, etc so I have quite a few date extra fields which are the ones that are creating these error messages and preventing the creation of new K2 items.

As you can see the problem is due to incorrect formatting of the date fields, and the issue is that I cannot find a way to add a reliable validation for these fields. I did a template override of itemform.php and added javascript to force the users to use the datepickers and to validate the format of the date fields. Even when date pickers are used there could still be format issues due to different date formats used by computers in different parts of the world. However, even if the javascript is hardcoded at itemform.php it does not seem to work in many cases.

Other people seem to be having similar issues as per
www.joomlaworks.net/forum/k2-en/40132-problems-with-field-validation

But it doesn't seem to be a clear solution

So how can we reliably check with regular expressions that the content of the fields is correct? And show appropriate error messages when the format is not correct? Prior to running into ugly error messages as per the one shown above and users losing all the populated info.

Please provide some advice or guiding

Many thanks!

Please Log in or Create an account to join the conversation.

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
8 years 10 months ago #145709 by Krikor Boghossian
Replied by Krikor Boghossian on topic Validation in the frontend submit form
Hello Daniel,

Is there a link to the form?
Also which version of K2 and Joomla! are you using?

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.


Powered by Kunena Forum