Block Field Validation
Permalink
Whats the best way to validate fields on the edit popup for a block.
All i want to be able to do is make it unable to save if the field is empty.
I could write my own JS validation in the auto.js to run when someone clicks on the save button, but for something so universal i would have thought there would be some form of validation built in to block add/edit i can hook into.
Searched the highs and lows of the concrete 5 documentation but cant find anything on this, if someone can point me in the right direction or give me some insight would be appreciated.
Thanks.
All i want to be able to do is make it unable to save if the field is empty.
I could write my own JS validation in the auto.js to run when someone clicks on the save button, but for something so universal i would have thought there would be some form of validation built in to block add/edit i can hook into.
Searched the highs and lows of the concrete 5 documentation but cant find anything on this, if someone can point me in the right direction or give me some insight would be appreciated.
Thanks.
After adding this it appears to work (notices the empty field and throws an error) but then when I add text to the field and click save again I get "An unexpected error occurred. Call to a member function setBlockAreaObject() on null" and i have to refresh the page to try again which results in the same outcome.
What do you have for your entire block controller? I can take a look.
removed code as got no replys
The above does two things. First, it checks to see if the recipe title is empty, and if so, it gives an error. Second, it checks to see if the recipe title is more than 255 characters long. If it is, it gives an error.
That's just a sample from my free EZ Recipe block, which you can download as an example here:
https://www.concrete5.org/marketplace/addons/ez-recipe...