When setting a field to required... what MAKES it required?

Permalink Browser Info Environment
Is it just the entry in the auto.js file? Or is there something that gets set on the database end to enforce/require a field to be non-null?

The only think I've found any evidence of is the validation occurring in the block's auto.js file.

Thanks!

- John

Type: Discussion
Status: New
arrestingdevelopment
View Replies: View Best Answer
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Yes, validation in C5 blocks only occurs in the auto.js file. Seehttp://c5cookbook.com/recipes/block_form_validation... for more details.

If you are getting into web programming, you will often hear that validation should occur on the server, not just the client. So at first the C5 way threw me for a loop. But the thing is that someone editing a block is never going to be trying to intentionally mess with the system or circumvent your precautions -- *AND* since javascript is required to use C5's editing interface in the first place, you can rely on it being in place. So this is a special case where it's okay to validate on the front-end only.
jordanlev replied on at Permalink Reply
jordanlev
All that being said, I have discovered recently that if you put a "validate" function in your block controller, it does appear to get called to perform validation as well. But it's not documented anywhere (grr...), and I haven't tested it out to see if it actually works, how you use it (i.e. how you get the submitted data to test and then how you report back success/failure and the error messages).
So for the time being it's still best to just stick with the auto.js validation.
arrestingdevelopment replied on at Permalink Reply
arrestingdevelopment
Thanks, Jordan. That makes perfect sense, knowing the audience of WHO is filling these forms out, etc. I was just surprised when I was working on editing a block and realized that there weren't any functions for validation in the controller... and the ONLY place I saw anything was in the JS file. When I normally code forms, I first code the backend validation and then progressively enhance it with JS for a better user-experience... that degrades gracefully in the (rare) case the visitor doesn't have JS.

Thanks for the info!

- John

concrete5 Environment Information

Browser User-Agent String

Hide Post Content

This will replace the post content with the message: "Content has been removed by an Administrator"

Hide Content

Request Refund

You have not specified a license for this support ticket. You must have a valid license assigned to a support ticket to request a refund.