本文整理汇总了PHP中Zend_Form_Element::setLabel方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element::setLabel方法的具体用法?PHP Zend_Form_Element::setLabel怎么用?PHP Zend_Form_Element::setLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element
的用法示例。
在下文中一共展示了Zend_Form_Element::setLabel方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
$this->setMethod('post');
$cat = new Zend_Form_Element_Select('G_P_CAT');
$cat->setLabel('Kategorie: ')->addValidator('alnum')->setRequired(true)->addMultiOptions(array('Adresse' => 'Adresse', 'Falle' => 'Falle', 'Brutstätte' => 'Brutstätte'));
$name = new Zend_Form_Element_Text('G_P_NAME');
$name->setLabel('Name: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
$lat = new Zend_Form_Element('G_P_LAT');
$lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
$lng = new Zend_Form_Element('G_P_LNG');
$lng->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
$submit = new Zend_Form_Element_Submit('senden');
$this->addElements(array($name, $cat, $lat, $lng, $submit));
}
示例2: init
public function init()
{
$this->setMethod('post');
$typ = new Zend_Form_Element_Select('G_TYP');
$typ->setLabel('Typ: ')->addValidator('alnum')->setRequired(true)->addMultiOptions(array(1 => 'Adresse', 2 => 'Falle', 3 => 'Brutstätte'));
$name = new Zend_Form_Element_Text('G_NAME');
$name->setLabel('Name: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
$lat = new Zend_Form_Element('G_LAT');
$lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
$lon = new Zend_Form_Element('G_LON');
$lon->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
$submit = new Zend_Form_Element_Submit('senden');
$this->addElements(array($name, $typ, $lat, $lon, $submit));
}
示例3:
/**
* Creates the registration form and it's elements.
* Also sets the validation techniques for the fields
*/
function __construct()
{
parent::__construct();
$this->setName('Registration');
$this->setMethod('POST');
$this->setAction('/user/register');
$username = new Zend_Form_Element('username');
$username->setLabel('Username');
$username->setRequired(true);
$username->addValidator('NotEmpty', true);
$username->addValidator(new Zend_Validate_StringLength(6, 10), true);
$username->addValidator('Alnum', true);
$username->addValidator(new User_Models_Forms_Validators_IsUnique('username'));
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password');
$password->setRequired(true);
$password->addValidator('NotEmpty', true);
$password->addValidator(new Zend_Validate_StringLength(6, 10));
$gender = new Zend_Form_Element_Select('gender');
$gender->setLabel('Gender');
$gender->setMultiOptions(array('Male' => 'Male', 'Female' => 'Female'));
$email = new Zend_Form_Element_Text('email');
$email->setLabel('Email');
$email->setRequired(true);
$email->addValidator('NotEmpty', true);
$email->addValidator(new User_Models_Forms_Validators_EmailAddress(), true);
$email->addValidator(new User_Models_Forms_Validators_IsUnique('email'));
$paymentEmail = new Zend_Form_Element_Text('paymentEmail');
$paymentEmail->setLabel('Payment Email');
$paymentEmail->setRequired(true);
$paymentEmail->addValidator('NotEmpty', true);
$paymentEmail->addValidator(new User_Models_Forms_Validators_EmailAddress(), true);
$paymentEmail->addValidator(new User_Models_Forms_Validators_IsUnique('paymentEmail'));
$countries = new Zend_Form_Element_Select('country');
$countries->setMultiOptions(self::getCountries());
$countries->setLabel('Country');
$countries->addValidator('NotEmpty');
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Register');
$this->addElements(array($username, $password, $gender, $email, $paymentEmail, $countries, $submit));
}
示例4:
function __construct()
{
parent::__construct();
$this->setName('Registration');
$this->setMethod('POST');
$this->setAction('/user/login');
$username = new Zend_Form_Element('username');
$username->setLabel('Username');
$username->setRequired(true);
$username->addValidator('NotEmpty', true);
$username->addValidator(new Zend_Validate_StringLength(6, 10));
$username->addValidator('Alnum', true);
$password = new Zend_Form_Element_Password('password');
$password->setLabel('Password');
$password->setRequired(true);
$password->addValidator('NotEmpty', true);
$password->addValidator(new Zend_Validate_StringLength(6, 10));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Register');
$this->addElements(array($username, $password, $submit));
}
示例5: setupSingleElement
/**
* Setup per-element properties like labels, and classes
*/
protected function setupSingleElement(Zend_Form_Element $elm)
{
// determine if this element has an error. (Will be used below)
$elmHasError = count($elm->getMessages()) > 0;
// set element values from the language pack
$elm->setLabel($this->lang->get('form.label.' . $elm->getName()));
// display info about required length if validator exists
if ($elm->getValidator('StringLength')) {
$elm->setDescription(sprintf($this->lang->get('form.description.' . $elm->getName()), $elm->getValidator('StringLength')->getMin(), $elm->getValidator('StringLength')->getMax()));
} else {
$elm->setDescription($this->lang->get('form.description.' . $elm->getName()));
}
// Duplicating type attr to classname in case we need to support IE6
// and want to be able to directly target the element without using
// input[type=text]
$zendType = $elm->getType();
$className = strtolower(substr($zendType, strrpos($zendType, '_') + 1));
$elm->setAttrib('class', $className);
// wrap this stuff up in a html div with class 'element'
$elm->addDecorator('HtmlTag', array('tag' => 'div', 'class' => 'element'));
// determine if element has error and use that to determine prefix char.
// 1. There seems to be no way to add html to the reqPrefix
// 2. There seems to be no way to add a custom classname to the div tag
if ($elm->getName() != 'submit') {
$reqChar = $elmHasError ? '! ' : '* ';
$elm->addDecorator('Label', array('placement' => 'prepend', 'tag' => 'div', 'requiredPrefix' => $reqChar));
}
// use custom error decorator that attempts to replace default error
// messages by the ones supplied by My_LanguagaPack
$errorDecorator = new My_Decorator_Errors();
$errorDecorator->setLanguagePack($this->lang);
$elm->addDecorator($errorDecorator);
// wrap everything so far in a li tag, give it class error if elm has error
// ATT: using array to create alias for allready used HtmlTag decorator
$liClass = $elmHasError ? 'error' : '';
$elm->addDecorator(array('outerLi' => 'HtmlTag'), array('tag' => 'li', 'class' => $liClass));
}
示例6: init
public function init()
{
$this->setMethod('post');
$g_name = new Zend_Form_Element_Text('G_NAME');
$g_name->setLabel('Name des Punktes: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
$lat = new Zend_Form_Element('G_LAT');
$lat->setLabel('Lat: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
//->setAttrib('disabled', 'true');
$lon = new Zend_Form_Element('G_LON');
$lon->setLabel('Lon: ')->setRequired(true)->addValidator('Between', true, array(0, 180));
//->setAttrib('disabled', 'true');
$b_name = new Zend_Form_Element_Text('B_NAME');
$b_name->setLabel('Name der Brutstaette: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setRequired(true);
$groesse = new Zend_Form_Element('B_GROESSE');
$groesse->setLabel('Größe: ')->setRequired(true)->addValidator('Int')->addValidator('Between', true, array(0, 100));
$gewaesser_art = new Zend_Form_Element_Text('B_GEWAESSER_ART');
$gewaesser_art->setLabel('Gewässer Art: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
$zugang = new Zend_Form_Element_Text('B_ZUGANG');
$zugang->setLabel('Zugang: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
$bek_art = new Zend_Form_Element_Text('B_BEK_ART');
$bek_art->setLabel('Bekämpfung Art: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true));
$text = new Zend_Form_Element_Textarea('B_TEXT');
$text->setLabel('Text: ')->addValidator('Alnum', true, array('allowWhiteSpace' => true))->setAttrib('rows', '5')->setAttrib('cols', '50');
$submit = new Zend_Form_Element_Submit('senden');
$this->addElements(array($g_name, $lat, $lon, $b_name, $groesse, $gewaesser_art, $zugang, $bek_art, $text, $submit));
//Layout
$this->addDisplayGroup(array('G_NAME', 'G_LAT', 'G_LON'), 'geopoint', array('legend' => 'Koordinaten des Punktes'));
$contact = $this->getDisplayGroup('geopoint');
$contact->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('tag' => 'div', 'openOnly' => true, 'style' => 'float:left;'))));
$this->addDisplayGroup(array('B_NAME', 'B_GROESSE', 'B_GEWAESSER_ART', 'B_ZUGANG', 'B_BEK_ART', 'B_TEXT'), 'brutstaette', array('legend' => 'Daten zur Brutstaette'));
$pass = $this->getDisplayGroup('brutstaette');
$pass->setDecorators(array('FormElements', 'Fieldset', array('HtmlTag', array('style' => 'float:right'))));
$this->addDisplayGroup(array('senden'), 'submitbutton', array('legend' => 'Daten Abschicken'));
$pass = $this->getDisplayGroup('submitbutton');
$pass->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'closeOnly' => true, 'style' => 'float:left'))));
$this->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'div', 'style' => 'width:98%')), 'Form'));
}
示例7: 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;
}
示例8: setLabel
public function setLabel($label)
{
$this->setAttrib('label', $label);
return parent::setLabel($label);
}
示例9: testRenderCanReplaceContent
public function testRenderCanReplaceContent()
{
$callback = 'Zend_Form_Decorator_CallbackTest_TestCallback';
$element = new Zend_Form_Element('foobar');
$element->setLabel('Label Me');
$this->decorator->setOptions(array('callback' => $callback, 'placement' => false))->setElement($element);
$content = $this->decorator->render('foo bar');
$this->assertNotContains('foo bar', $content, $content);
$this->assertContains($element->getName(), $content);
$this->assertContains($element->getLabel(), $content);
}
示例10: replaceElement
/**
*
* @param Zend_Form_Element|string $element
* @return Zend_Form_Element
*/
public function replaceElement($element)
{
$name = $element->getName();
$previousElement = $this->getElement($name);
if ($previousElement) {
$label = $this->getElement($name)->getLabel();
$element->setLabel($label);
}
$this->addElement($element);
return $this;
}