Welcome Guest, Not a member yet? Register   Sign In
Crossfire base project
#11

(10-30-2015, 02:43 PM)iamthwee Wrote: Here's my biggest problem with the validation pattern. Let's say you have some jquery which opens a hidden div when you check a checkbox and the user inputs something wrong, how do you validate server side then reload the view but open that div with bad values filled in? The only robust way I could think about doing it was temporarily saving the form as a json array.

Take a step back, and don't hide the extra form inputs. Display them. I did it this way, and realised that showing/hiding these input fields has nothing todo with the validation. You will need extra javascript that does this. True, it is triggered by certain values. But the rules of the checkbox don't have anything to do with the related field that is hidden or shown on value selection. The rule of the related field will check if it's parent (the checkbox) has been checked, when true validate it's value. But checking the checkbox maybe is not even required.
When server side validation fails for any reason and the form is reloaded, it will be the extra javascript that you must use on page load to display the extra fields.
In my case, the hidden field is defined in the form fields array and not added dynamically with javascript. Meaning that with a faild validation the error holder is added and I can display the error, if present, for the "hidden" extra field.
Reply
#12

Can you give me a working example, now I'm interested.
Practical guide to IgnitedCMS - Book coming soon, www.ignitedcms.com
Reply
#13

(10-31-2015, 12:57 AM)iamthwee Wrote: Can you give me a working example, now I'm interested.

My working version is quite messy Tongue
The form builder library is a refactoring of my original that I have been using for quite sometime. But the time was now and available to redo it. Like I said, I hope to have the first draft finished within the next week.
Reply




Theme © iAndrew 2016 - Forum software by © MyBB