I need to show the error messages in View
Here is my code:
This is my form code:
public function initialize() {
$name = new Text('name', array(
'class' => 'form-control',
"placeholder" => "Type your name"
));
$name->addValidators(array(
new PresenceOf(array(
'message' => 'Please enter your username.',
)),
));
$this->add($name);
}
Here is my html code:
<form method="post" action="user">
<p>
<label>
Name
</label>
<?php echo $userForm->render("name"); ?>
</p>
<p>
<input type="submit" value="Save" />
</p>
</form>
Here is my controller file code:
public function indexAction()
{
$userform = new UserForm();
$this->view->userForm = $userform;
if($this->request->isPost()) {
if($userform->isValid($_POST)) {
}
}
}
Any help is greatly appreciated. Thanks in advance.
Will quote the docs.
Or get specific messages for an element:
More information in the Docs.