本文整理汇总了PHP中Zend_Form_Element::getValidators方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::getValidators方法的具体用法?PHP Zend_Form_Element::getValidators怎么用?PHP Zend_Form_Element::getValidators使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element
的用法示例。
在下文中一共展示了Zend_Form_Element::getValidators方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: _generateValidationRules
/**
* Generate the JavaScript code for the validation rules
* @param Zend_Form_Element $element
* @return string
*/
protected function _generateValidationRules(Zend_Form_Element $element)
{
$name = $element->getName();
$formName = $this->_formName;
$validators = $element->getValidators();
$rules = array();
foreach ($validators as $validator) {
$class = get_class($validator);
$params = $this->_generateValidatorParameters($class, $validator);
$rules[] = "{ name: '{$class}', parameters: {$params} }";
}
if (count($rules) > 0) {
$script = $this->_formNamespace . "." . $this->_formName . ".{$name} = [ " . implode(', ', $rules) . " ];\r\n";
}
return $script;
}