本文整理汇总了PHP中Zend_Form_Element::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::hasErrors方法的具体用法?PHP Zend_Form_Element::hasErrors怎么用?PHP Zend_Form_Element::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element
的用法示例。
在下文中一共展示了Zend_Form_Element::hasErrors方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: aElement
/**
* Render element
*
* @param Zend_Form_Element $element
* @return string
*/
public function aElement(Zend_Form_Element $element)
{
$viewClasses = array($element->getAttrib('class'));
if ($element->isRequired()) {
if (!$element->getAttrib('title')) {
$element->setAttrib('title', 'Field is required');
}
$viewClasses[] = 'aForm-field-required';
}
if ($element->getValidators()) {
$viewClasses[] = 'aForm-field-validate';
}
if ($element->hasErrors()) {
$viewClasses[] = 'aForm-field-invalid';
} elseif ($element->getValue() || !$element->isRequired()) {
$viewClasses[] = 'aForm-field-valid';
}
if ($element->getValidators()) {
$viewClasses[] = 'aForm-field-validate';
}
$element->setAttrib('class', implode(' ', $viewClasses));
$options = null;
$separator = null;
if ($element instanceof Zend_Form_Element_Multi) {
$options = $element->getMultiOptions();
$separator = $element->getSeparator();
}
return $this->view->{$element->helper}($element->getName(), $element->getValue(), $element->getAttribs(), $options, $separator);
}
示例2: buildInput
/**
* Construit un champ de type input (générique) avec le helper de Zend correspondant a ce champ
*
* @brief construit un champ générique
* @author francoisespinet
* @param Zend_Form_Element $oElement
*/
protected function buildInput(Zend_Form_Element $oElement, $bNoErreurs = false)
{
//ajout des erreurs si besoin
if ($oElement->getAttrib(self::FORM_HAS_ERROR) && !$bNoErreurs) {
return $this->formAddErreurChamp($oElement->renderViewHelper(), $oElement->hasErrors());
} else {
return $oElement->renderViewHelper();
}
}
示例3: renderFormElement
/**
* Enter description here ...
* @param Zend_Form_Element $element
* @author Tung Ly
*/
public function renderFormElement($element, $vertical = 0)
{
if ($element->getType() != "Zend_Form_Element_Checkbox") {
$element->setAttrib('class', $element->getAttrib('class') . ' form-control');
}
if ($element->isRequired()) {
$element->setLabel($element->getLabel() . ' *');
$element->setAttrib('class', $element->getAttrib('class') . ' required');
}
switch ($element->getType()) {
case 'Zend_Form_Element_Textarea':
$element->setAttrib('rows', 5);
$element->setAttrib('cols', 80);
break;
case 'Zend_Form_Element_Hidden':
return $element;
default:
break;
}
$error = '';
if ($element->hasErrors()) {
$error = 'has-error';
}
if ($element->getType() == 'Zend_Form_Element_Textarea') {
}
$btn = array('Zend_Form_Element_Submit', 'Zend_Form_Element_Reset');
if (in_array($element->getType(), $btn)) {
//$t ='<button type="reset" class="btn"><i class="icon-refresh"></i> '.$element->getLabel().'</button>';
$t = '<div class="span2">' . $element . '</div>';
} else {
$label = trim(preg_replace("/([A-Z])/", " \$1", "{$element->getLabel()}"), ' ');
$variables = array('%%ERROR_CLASS%%' => $error, '%%ELEMENT_NAME%%' => $element->getName(), '%%ELEMENT_LABEL%%' => $label, '%%ELEMENT%%' => $element, '%%HELP_MESSAGE%%' => current($element->getMessages()));
$t = str_replace(array_keys($variables), $variables, $this->_getTemplate($vertical));
}
return $t;
}