Created
July 12, 2014 19:31
-
-
Save j4k/c2d47da7f1536ffebc68 to your computer and use it in GitHub Desktop.
Concrete 5 Form Validation Helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $val = Loader::helper('validation/form'); | |
| $data = array( | |
| 'name' => 'Jane Doe', | |
| 'email' => '', | |
| 'website' => 'http://example.com', | |
| 'content' => 'Great Post!' | |
| ); | |
| $val->setData($data); | |
| $val->addRequired('name', 'Please enter a name.'); | |
| $val->addRequiredEmail('email', 'Please enter an email address'); | |
| $val->addRequired('content', 'Please enter some content'); | |
| $passed = $val->test(); | |
| if($passed === false){ | |
| foreach ($val->getError()->getList() as $error) { | |
| echo $error . '<br />'; | |
| } | |
| } | |
| exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment