Keyword

Problems with field validation

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #140721 by Alan Campbell
Problems with field validation was created by Alan Campbell
Hello again!

I'm having some trouble with K2 Extra Fields.

I have a front end editing form that I want all fields to be required and need to validate the data entered. Unfortunately, validation isn't working.

I have had this problem since I had vanilla K2 plus vanilla Joomla. I tried lots of different was to get around it to no avail.
- Using different templates
- Disabling templates on the user form
- Using the Joomla validation (which is turned on in the example below but has no effect)
- JQuery no-conflict mode


To see the issue:
Go to chl.soc.srcf.net/quid/
Click on the three little bars at top-left to open the login panel.
Log in with the test credentials:
User = testymctest
Pass = test

Then go to chl.soc.srcf.net/quid/submit-a-project

The form only seems to require title and dates, despite me setting all to required in the backend.

Dates aren't validated at all and you can enter anything without validation---this causes the site to freak out whenever this item is shown with a DateTime parse error. So there's no validation on front or backend.

Can anyone help me?

Alan

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #140743 by Krikor Boghossian
Replied by Krikor Boghossian on topic Problems with field validation
Hello Alan,

Browsing your form I can see that the textarea's are not required while, the radio buttons are.
Can you send a printscreen of the settings of a textarea field?

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

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago - 9 years 3 months ago #140750 by Alan Campbell
Replied by Alan Campbell on topic Problems with field validation
Hello Krikor,

Many thanks for your prompt reply.

I have uploaded a screen shot here:http://imgur.com/D2vTovT

The issue seems to be three fold:
- client side validation by JavaScript is not working, so invalid dates etc are allowed; It only prevents submission with no title
- server side validation only works for checking required dates
- the server side only adds K2Required class to some fields.

I mentioned the hacks I've tried but none were successful.

I'm not sure what I've done wrong!

Thanks for your help!
Last edit: 9 years 3 months ago by Alan Campbell.

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

  • Krikor Boghossian
  • Krikor Boghossian's Avatar
  • Offline
  • Platinum Member
More
9 years 3 months ago #140764 by Krikor Boghossian
Replied by Krikor Boghossian on topic Problems with field validation
I can see an extra class ACExtraFieldCaption.
Are you using any 3rd party K2 extensions?

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

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #140775 by Alan Campbell
Replied by Alan Campbell on topic Problems with field validation
Hello again,

This is a class I made. I'm making sub labels for the fields by parsing the label name.

This change was made after the problem with the validation was found. I also tested without it and there was no difference.

Thanks again,

Alan

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 3 months ago #140783 by Alan Campbell
Replied by Alan Campbell on topic Problems with field validation
Hello again,

I've made a form with only the default template code here:
chl.soc.srcf.net/quid/ongoing-projects

Again, cient side and server side checks aren't performed.

This allows required fields (as set in the backend) to be skipped and data not validated.

As invalid dates can be entered, the site fails with a fatal error about parsing the DateTime when you view the item/category.

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

More
9 years 2 months ago #140811 by Lefteris
Replied by Lefteris on topic Problems with field validation
@Alan Campbell

Can you try this fix and let me know if it solves your issue ? github.com/joomlaworks/k2/commit/63b2c9a35e4cf69c2f3b78e3dde036f6ea604ddd

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

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 2 months ago #140834 by Alan Campbell
Replied by Alan Campbell on topic Problems with field validation
Lefteris,

Many thanks for both your help and fix. I'm not great at navigating Github so hadn't found this.

Your fix seems to have corrected the missing required fields check/css class! Thank you very much for your help on this.


Unfortunately, data is still not validated for correct data format. I tried putting in random data, including letters instead of dates,and the input is accepted which then causes the site to crash. Here is an example error:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AND trash = 0' at line 1 SQL=SELECT MAX(ordering) FROM o4h6s_k2_items WHERE catid = AND trash = 0

Again, the testing page is at: chl.soc.srcf.net/quid/ongoing-projects

Login testymctest
password test

Separate to this, I've also noticed that changing the category isn't the drop down menu loses all my custom template changes (I guess because the fields are reloaded via. Ajax ? ). Is this a known error?Should I start a new forum topic for it?

Pleaser can you advise of any ideas on how to fix these

Alan

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

More
9 years 2 months ago #140847 by Lefteris
Replied by Lefteris on topic Problems with field validation
There is no data type validation in extra fields. Also the fields are indeed loaded via AJAX. What kind of changes you have applied?

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

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

  • Alan Campbell
  • Alan Campbell's Avatar Topic Author
  • Offline
  • Junior Member
More
9 years 2 months ago #140866 by Alan Campbell
Replied by Alan Campbell on topic Problems with field validation
Dear Lefteris,

Many thanks for your reply.

So, data fields aren't type-validated? As invalid data throws a fatal error, I've gotten around this by making the fields read only, relying on the calendar javascript. Just in case anyone else is looking for a semi-solution!

I have changed formats and modify presentation of (for example) the field labels. I achieved this by making a custom template for K2 and selecting it as the layout for the category.

For example, if you go to:
chl.soc.srcf.net/quid/completed-projects/item/edit/15?tmpl=component
having logged in as testymctest, pass = test, and change between Ongoing and Completed categories (NB I've renamed the category field as Project Status, it's under the Title field) - you will see that I lose my label formatting.

Thanks again for your help - I really do appreciate this!

Alan

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


Powered by Kunena Forum