本文整理汇总了PHP中Zend_Form_Element::isRequired方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::isRequired方法的具体用法?PHP Zend_Form_Element::isRequired怎么用?PHP Zend_Form_Element::isRequired使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element
的用法示例。
在下文中一共展示了Zend_Form_Element::isRequired方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}
示例3: testPassingConfigObjectToConstructorSetsObjectState
public function testPassingConfigObjectToConstructorSetsObjectState()
{
$config = new Zend_Config($this->getOptions());
$element = new Zend_Form_Element($config);
$this->assertEquals('changed', $element->getName());
$this->assertEquals('foo', $element->getValue());
$this->assertEquals('bar', $element->getLabel());
$this->assertEquals(50, $element->getOrder());
$this->assertFalse($element->isRequired());
$this->assertEquals('bar', $element->foo);
$this->assertEquals('bat', $element->baz);
}
示例4: applyCustomMessages
/**
* Fügt angepasste Nachrichten für Validierungen hinzu.
* @param Zend_Form_Element $element
*/
protected function applyCustomMessages($element)
{
if ($element->isRequired()) {
// wenn Validator 'notEmpty' bereits gesetzt ist; nicht modifizieren
if (!$element->getValidator('notEmpty') && $element->autoInsertNotEmptyValidator()) {
$notEmptyValidator = new Zend_Validate_NotEmpty();
$notEmptyValidator->setMessage('admin_validate_error_notempty');
$element->addValidator($notEmptyValidator);
}
}
}
示例5: getLabelHTML
/**
* Gets html content fot label
*
* @param Zend_Form_Element $element
* @return string
*/
protected function getLabelHTML($element)
{
$label = $element->getLabel();
if ($translator = $element->getTranslator()) {
$label = $translator->translate($label);
}
$label = $element->getView()->formLabel($element->getName(), $label);
if ($element->isRequired()) {
$label .= '<span class="asterisk">*</span>';
}
return $label;
}