本文整理汇总了PHP中Zend_Form_Element_Select::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form_Element_Select::setOptions方法的具体用法?PHP Zend_Form_Element_Select::setOptions怎么用?PHP Zend_Form_Element_Select::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form_Element_Select
的用法示例。
在下文中一共展示了Zend_Form_Element_Select::setOptions方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: init
public function init()
{
// if (!$this->hasTranslator()) {
// $this->setTranslator(Zend_Registry::get('Zend_Translate'));
// }
$userid = new Zend_Form_Element_Hidden('UserID');
$userid->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
$username = new Zend_Form_Element_Text('Username');
$username->setOptions(array('label' => 'Username', 'required' => TRUE))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$birthday = new Zend_Form_Element_Text('Birthday');
$birthday->setOptions(array('label' => 'Birthday', 'required' => TRUE))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$role = new Zend_Form_Element_Select('Role');
$role->setOptions(array('label' => 'User Type', 'MultiOptions' => array(3 => 'User', 2 => 'IT', 1 => 'Admin', 0 => 'SuperAdmin')))->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label', array('class' => 'label'))));
$fullname = new Zend_Form_Element_Text('FullName');
$fullname->setOptions(array('label' => 'FullName'))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$email = new Zend_Form_Element_Text('Email');
$email->setOptions(array('label' => 'Email', 'required' => TRUE))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$group = new Zend_Form_Element_Text('Group');
$group->setOptions(array('label' => 'Group'))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$phone = new Zend_Form_Element_Text('Phone');
$phone->setOptions(array('label' => 'Phone'))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$address = new Zend_Form_Element_Textarea('Address');
$address->setOptions(array('label' => 'Address', 'style' => "width: 200px; height: 150px"))->setDecorators(array(array('ViewHelper', array('helper' => 'formTextarea')), array('Label', array('class' => 'label'))));
$this->setName('user-form')->setMethod(Zend_Form::METHOD_POST)->setEnctype(Zend_Form::ENCTYPE_URLENCODED)->addElements(array($userid, $username, $role, $fullname, $email, $birthday, $group, $phone, $address))->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset', 'style' => "padding: 0; border: 0; margin-top: 25px;")), 'Form'));
}
示例2: init
public function init()
{
// if (!$this->hasTranslator()) {
// $this->setTranslator(Zend_Registry::get('Zend_Translate'));
// }
$itemid = new Zend_Form_Element_Hidden('ItemID');
$itemid->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
$maTS = new Zend_Form_Element_Text('MaTS');
$maTS->setOptions(array('label' => 'Mã TS', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$tenTS = new Zend_Form_Element_Text('TenTS');
$tenTS->setOptions(array('label' => 'Tên tài sản', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$descr = new Zend_Form_Element_Textarea('Description');
$descr->setOptions(array('label' => 'Mô tả', 'style' => "width: 200px; height: 50px"))->setDecorators(array(array('ViewHelper', array('helper' => 'formTextarea')), array('Label', array('class' => 'label'))));
$type = new Zend_Form_Element_Select('Type');
$type->setOptions(array('label' => 'Loại bảo mật', 'required' => TRUE, 'MultiOptions' => array(1 => 'Bảo mật thấp', 0 => 'Bảo mật cao')))->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label', array('class' => 'label'))));
$startDate = new Zend_Form_Element_Text('StartDate');
$startDate->setOptions(array('label' => 'Bắt đầu SD', 'required' => TRUE))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$price = new Zend_Form_Element_Text('Price');
$price->setOptions(array('label' => 'Giá', 'required' => TRUE, 'filters' => array('Int')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$warrantyTime = new Zend_Form_Element_Text('WarrantyTime');
$warrantyTime->setOptions(array('label' => 'Bảo hành', 'required' => TRUE, 'filters' => array('Int')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$status = new Zend_Form_Element_Select('Status');
$status->setOptions(array('label' => 'Tình trạng', 'required' => TRUE, 'MultiOptions' => array(0 => 'Có thể mượn', 1 => 'Đang cho mượn', 2 => 'Hỏng')))->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label', array('class' => 'label'))));
$place = new Zend_Form_Element_Textarea('Place');
$place->setOptions(array('label' => 'Địa điểm hiện tại', 'style' => "width: 200px; height: 50px"))->setDecorators(array(array('ViewHelper', array('helper' => 'formTextarea')), array('Label', array('class' => 'label'))));
$this->setName('item-form')->setMethod(Zend_Form::METHOD_POST)->setEnctype(Zend_Form::ENCTYPE_URLENCODED)->addElements(array($itemid, $maTS, $tenTS, $descr, $type, $startDate, $price, $warrantyTime, $status, $place))->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset', 'style' => "padding: 0; border: 0; margin-top: 25px;")), 'Form'));
}
示例3: init
public function init()
{
$this->setName('transfer_source');
$this->setAttrib('class', 'form-inline');
$host1 = new Zend_Form_Element_Text('host1');
$host1->setAttrib('class', 'form-control')->setLabel('host1')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('Hostname');
$edit = new Zend_Form_Element_Hidden('edit');
//$edit->setLabel('Edition Mode');
//$edit->clearDecorators();
$host1->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group col-md-3'))));
$user1 = new Zend_Form_Element_Text('user1');
$user1->setLabel('user1')->setAttrib('class', 'form-control')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty')->addValidator('EmailAddress');
$user1->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group col-md-3'))));
$password1 = new Zend_Form_Element_Text('password1');
$password1->setLabel('pass1')->setAttrib('class', 'form-control')->setRequired(true)->addFilter('StripTags')->addFilter('StringTrim')->addValidator('NotEmpty');
$password1->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group col-md-3'))));
$action = new Zend_Form_Element_Select('action');
$action->setOptions(array('1' => 'source', '2' => 'target'));
$action->setAttrib('class', 'form-control');
$action->options = array('1' => 'source', '2' => 'target');
$action->setDecorators(array('ViewHelper', 'Description', 'Errors', 'Label', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group col-md-2'))));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Submit');
$submit->setAttrib('class', 'btn btn-default');
$submit->setAttrib('value', 'transfer_source');
$submit->setDecorators(array('ViewHelper', 'Description', 'Errors', array(array('data' => 'HtmlTag'), array('tag' => 'div', 'colspan' => 2, 'align' => 'center')), array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'form-group'))));
$this->addElements(array($edit, $host1, $user1, $password1, $action, $submit));
$this->setDecorators(array('FormElements', 'Form'));
}
示例4: init
public function init()
{
// if (!$this->hasTranslator()) {
// $this->setTranslator(Zend_Registry::get('Zend_Translate'));
// }
$requestid = new Zend_Form_Element_Hidden('RequestID');
$requestid->setDecorators(array(array('ViewHelper', array('helper' => 'formHidden'))));
$maTS = new Zend_Form_Element_Text('MaTS');
$maTS->setOptions(array('label' => 'Mã TS', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
//
// $UserID = new Zend_Form_Element_Text('UserID');
// $UserID->setOptions(array(
// 'label' => 'UserID',
// 'required' => TRUE,
// 'filters' => array('StringTrim')
// ))
// ->setDecorators(array(
// array('ViewHelper', array('helper' => 'formText')),
// array('Label', array('class' => 'label'))
// ));
$utype = new Zend_Form_Element_Select('Type');
$utype->setOptions(array('label' => 'Loại yêu cầu', 'required' => TRUE, 'MultiOptions' => array(0 => 'Yêu cầu mượn TS', 1 => 'Yêu cầu nâng cấp')))->setDecorators(array(array('ViewHelper', array('helper' => 'formSelect')), array('Label', array('class' => 'label'))));
$detail = new Zend_Form_Element_Textarea('Detail');
$detail->setOptions(array('label' => 'Chi tiết yêu cầu', 'style' => "width: 200px; height: 100px"))->setDecorators(array(array('ViewHelper', array('helper' => 'formTextarea')), array('Label', array('class' => 'label'))));
$this->setName('item-form')->setMethod(Zend_Form::METHOD_POST)->setEnctype(Zend_Form::ENCTYPE_URLENCODED)->addElements(array($requestid, $maTS, $utype, $detail))->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset', 'style' => "padding: 0; border: 0; margin-top: 25px;")), 'Form'));
}
示例5: elementSelect
protected function elementSelect($title, $options, $conf = null)
{
$element = new Zend_Form_Element_Select($title);
if (is_array($options)) {
$element->setOptions($options);
} else {
$element->setLabel($options);
}
return $element;
}
示例6: init
public function init()
{
$name = new Zend_Form_Element_Text('Name');
$name->setOptions(array('label' => 'Name', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$email = new Zend_Form_Element_Text('Email');
$email->setOptions(array('label' => 'Email', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$subject = new Zend_Form_Element_Select('Subject');
$subject->setOptions(array('label' => 'Subject', 'required' => TRUE, 'filters' => array('StringTrim')))->setDecorators(array(array('ViewHelper', array('helper' => 'formText')), array('Label', array('class' => 'label'))));
$content = new Zend_Form_Element_Textarea('Content');
$content->setOptions(array('label' => 'Content', 'style' => "width: 300px; height: 200px"))->setDecorators(array(array('ViewHelper', array('helper' => 'formTextarea')), array('Label', array('class' => 'label'))));
$this->setName('item-form')->setMethod(Zend_Form::METHOD_POST)->setEnctype(Zend_Form::ENCTYPE_URLENCODED)->addElements(array($name, $email, $subject, $content))->setDecorators(array('FormElements', array('HtmlTag', array('tag' => 'fieldset', 'style' => "padding: 0; border: 0; margin-top: 25px;")), 'Form'));
}
示例7: init
/**
* Overrides init() in Zend_Form
*
* @access public
* @return void
*/
public function init()
{
// init the parent
parent::init();
// set the form's method
$this->setMethod('post');
$uniqueGroupNameValidator = new Zend_Validate_Db_NoRecordExists(array('table' => 'groups', 'field' => 'name'));
$groupModel = new Group();
$parentIdOptions = $groupModel->findPairs();
$name = new Zend_Form_Element_Text('name');
$name->setOptions(array('label' => 'Name', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty', $uniqueGroupNameValidator)));
$this->addElement($name);
$parentId = new Zend_Form_Element_Select('parent_id');
$parentId->setOptions(array('label' => 'Parent group', 'required' => true, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty'), 'multiOptions' => $parentIdOptions));
$this->addElement($parentId);
$id = new Zend_Form_Element_Hidden('id');
$id->setOptions(array('validators' => array(new Zend_Validate_Regex('/^\\d*$/'))));
$this->addElement($id);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setOptions(array('label' => 'Save user group', 'required' => true));
$this->addElement($submit);
}
示例8: init
/**
* Overrides init() in Zend_Form
*
* @access public
* @return void
*/
public function init()
{
// init the parent
parent::init();
// set the form's method
$this->setMethod('post');
$flagModel = new Flag();
$flagIdOptions = $flagModel->findPairs();
$name = new Zend_Form_Element_Text('name');
$name->setOptions(array('label' => 'Name', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
$this->addElement($name);
$flagId = new Zend_Form_Element_Select('flag_id');
$flagId->setOptions(array('label' => 'Flag', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty'), 'multiOptions' => $flagIdOptions));
$this->addElement($flagId);
$description = new Zend_Form_Element_Text('description');
$description->setOptions(array('label' => 'Description', 'required' => TRUE, 'filters' => array('StringTrim', 'StripTags'), 'validators' => array('NotEmpty')));
$this->addElement($description);
$id = new Zend_Form_Element_Hidden('id');
$id->setOptions(array('validators' => array(new Zend_Validate_Regex('/^\\d*$/'))));
$this->addElement($id);
$submit = new Zend_Form_Element_Submit('submit');
$submit->setOptions(array('label' => 'Save privilege', 'required' => TRUE));
$this->addElement($submit);
}