本文整理汇总了PHP中Zend_Form::getErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::getErrors方法的具体用法?PHP Zend_Form::getErrors怎么用?PHP Zend_Form::getErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::getErrors方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGetErrorsHonorsElementsBelongTo
public function testGetErrorsHonorsElementsBelongTo()
{
$subForm = new \Zend\Form\SubForm();
$subForm->setElementsBelongTo('foo[bar]');
$subForm->addElement('text', 'test')->test->setRequired(true);
$this->form->addSubForm($subForm, 'sub');
$data = array('foo' => array('bar' => array('test' => '')));
$this->form->isValid($data);
$codes = $this->form->getErrors();
$this->assertFalse(empty($codes['foo']['bar']['test']));
}
示例2: saveAction
public function saveAction()
{
$this->_helper->viewRenderer->setNoRender(true);
$message = array("success" => 0, "message" => "Please Correct the Errors Below!");
if ($this->_addForm->isValid($_POST)) {
//As everything is ok, save it...
$task = $this->_dataTable->createRow();
$task->name = $this->_addForm->getElement("name")->getValue();
$task->description = $this->_addForm->getElement("desc")->getValue();
$time = $this->_addForm->getElement("end_date")->getValue();
if (!empty($time)) {
$task->end_date = date("Y-m-d", strtotime($time));
}
$task->status = Task::STATUS_OPEN;
$task->save();
$message["success"] = 1;
$message["message"] = "Task is saved successfully! Wait For Redirection!";
} else {
$message["errors"] = $this->_addForm->getErrors();
}
echo json_encode($message);
}
示例3: getErrors
function getErrors($name = null, $suppressArrayNotation = false)
{
$e = parent::getErrors($name, $suppressArrayNotation);
if ($e) {
foreach ($e as &$el) {
if ($el) {
foreach ($el as &$el_1) {
$el_1 = $this->translateError($el_1);
}
}
}
}
return $e;
}
示例4: isFormElementError
/**
* Main method
* @param string The form object
* @param string Name of the element
* @return boolean
*/
public function isFormElementError(Zend_Form $form, $element)
{
return isset($form->getErrors($element));
}
示例5: mergeErrors
/**
* Helper function to merge different types of error.
*
* @param \Zend_Form $form The form.
* @param string $element The name of the element.
*
* @return array
*/
public static function mergeErrors($form, $elementName)
{
$elementErrors = $form->getErrors($elementName);
$element = $form->getElement($elementName);
if ($element && method_exists($element, 'getErrorMessages')) {
$elementCustomErrors = $element->getErrorMessages();
}
if (!is_array($elementErrors)) {
$elementErrors = array();
}
if (!is_array($elementCustomErrors)) {
$elementCustomErrors = array();
}
return array_merge($elementErrors, $elementCustomErrors);
}