本文整理汇总了PHP中Zend\Form\Element\Select::setValueOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::setValueOptions方法的具体用法?PHP Select::setValueOptions怎么用?PHP Select::setValueOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\Select
的用法示例。
在下文中一共展示了Select::setValueOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepareElements
public function prepareElements($topicList, $categoryList, $captchaOptions)
{
// repurpose $topicList and $categoryList
$topics = array('---' => 'Choose');
foreach ($topicList as $item) {
$topics[$item->item] = $item->item;
}
$categories = array('---' => 'Choose');
foreach ($categoryList as $item) {
$categories[$item->item] = $item->item;
}
$author = new Element\Hidden('author');
$category1 = new Element\Text('category');
$category1->setLabel('Category')->setAttribute('title', 'Enter a category: i.e. zf2 or use the dropdown list below')->setAttribute('size', 16)->setAttribute('maxlength', 16);
$category2 = new Element\Select('selectCategory');
$category2->setValueOptions($categories);
$topic1 = new Element\Text('topic');
$topic1->setLabel('Topic')->setAttribute('title', 'Enter a topic code: i.e. zf2f-2013-02-25 or use the dropdown list below')->setAttribute('size', 60)->setAttribute('maxlength', 254);
$topic2 = new Element\Select('selectTopic');
$topic2->setValueOptions($topics);
$title = new Element\Text('title');
$title->setLabel('Title')->setAttribute('title', 'Enter a suitable title for this posting')->setAttribute('size', 60)->setAttribute('maxlength', 254);
$body = new Element\Textarea('body');
$body->setLabel('Body')->setAttribute('title', 'Enter the body for this posting')->setAttribute('rows', 4)->setAttribute('cols', 60);
$captcha = new Element\Captcha('captcha');
$captchaAdapter = new Captcha\Image();
$captchaAdapter->setWordlen(4)->setOptions($captchaOptions);
$captcha->setCaptcha($captchaAdapter)->setLabel('Help us to prevent SPAM!')->setAttribute('class', 'captchaStyle')->setAttribute('title', 'Help to prevent SPAM');
$submit = new Element\Submit('submit');
$submit->setAttribute('value', 'Post')->setAttribute('title', 'Click here when done');
$this->add($author)->add($topic1)->add($topic2)->add($category1)->add($category2)->add($title)->add($body)->add($captcha)->add($submit);
}
示例2: addRoleElement
/**
* Add role element
*/
public function addRoleElement($options = array(), $name = 'role')
{
$element = new Select($name);
$element->setLabel('Benutzergruppe');
$element->setValueOptions($options);
$this->add($element);
}
示例3: __construct
public function __construct()
{
parent::__construct('add');
$hydrator = new AggregateHydrator();
$hydrator->add(new PostHydrator());
$hydrator->add(new CategoryHydrator());
$this->setHydrator($hydrator);
$title = new Element\Text('title');
$title->setLabel('Title');
$title->setAttribute('class', 'form-control');
$slug = new Element\Text('slug');
$slug->setLabel('Slug');
$slug->setAttribute('class', 'form-control');
$content = new Element\Textarea('content');
$content->setLabel('Content');
$content->setAttribute('class', 'form-control');
$category = new Element\Select('category_id');
$category->setLabel('Category');
$category->setAttribute('class', 'form-control');
$category->setValueOptions(array(1 => 'WIN', 2 => 'BUILD', 3 => 'SEND', 4 => 'GENERAL'));
$submit = new Element\Submit('submit');
$submit->setValue('Add News');
$submit->setAttribute('class', 'btn btn-primary');
$this->add($title);
$this->add($slug);
$this->add($content);
$this->add($category);
$this->add($submit);
}
示例4: __construct
/**
*
* @param null|string $name
*/
public function __construct($serviceLocator)
{
parent::__construct('transactionFilter');
$this->setServiceLocator($serviceLocator);
$this->setAttribute('method', 'GET');
$filter = $this->getInputFilter();
$id = new Text('id');
$id->setAttributes(['placeholder' => 'ID']);
$this->add($id);
$filter->add(array('name' => 'id', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits'))));
$companyId = $this->addElementCompany('companyId', null, ['required' => false]);
$transaction = new \Accounting\Model\Transaction();
$status = new Select('status');
$status->setValueOptions(['' => '- Trạng thái -'] + $transaction->getStatuses());
$this->add($status);
$filter->add(array('name' => 'status', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits'))));
$type = new Select('type');
$type->setValueOptions(['' => '- Loại phiếu -'] + $transaction->getTypes());
$this->add($type);
$filter->add(array('name' => 'type', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits'))));
$applyDateRange = new Text('applyDateRange');
$applyDateRange->setAttributes(array('placeholder' => 'Ngày hạch toán', 'class' => 'date-range-picker'));
$this->add($applyDateRange);
$filter->add(array('name' => 'applyDateRange', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
$createdByName = new Text('createdByName');
$createdByName->setAttributes(array('placeholder' => 'Người tạo'));
$this->add($createdByName);
$filter->add(array('name' => 'createdByName', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
$createdById = new Hidden('createdById');
$this->add($createdById);
$filter->add(array('name' => 'createdById', 'required' => false, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits'))));
$this->add(array('name' => 'submit', 'options' => array(), 'attributes' => array('type' => 'submit', 'value' => 'Lọc', 'id' => 'btnFilterCompanyContact', 'class' => 'btn btn-primary')));
}
示例5: __construct
public function __construct($serviceLocator, $options = null)
{
parent::__construct('fTransaction');
$this->setServiceLocator($serviceLocator);
$this->setAttribute('method', 'post');
$filter = $this->getInputFilter();
$basicGroup = new DisplayGroup('basicGroup');
$this->add($basicGroup);
$companyId = $this->addElementCompany('companyId', $basicGroup, ['required' => true]);
$applyDate = new Text('applyDate');
$applyDate->setLabel('Ngày hạch toán:');
$applyDate->setAttribute('class', 'datepicker');
$this->add($applyDate);
$basicGroup->addElement($applyDate);
$applyDate->setValue(DateBase::toDisplayDate(DateBase::getCurrentDate()));
$filter->add(array('name' => 'applyDate', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập ngày hạch toán'))))));
$description = new Text('description');
$description->setLabel('Nội dung:');
$this->add($description);
$basicGroup->addElement($description);
$filter->add(array('name' => 'description', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập nội dung phiếu thu'))))));
$accountId = new Select('accountId');
$accountId->setLabel('Quỹ thu:');
$accountId->setValueOptions(['' => '- Quỹ thu -']);
$this->loadAccountingAccount($accountId, $companyId);
$this->add($accountId);
$basicGroup->addElement($accountId);
$filter->add(array('name' => 'accountId', 'required' => true, 'filters' => array(array('name' => 'StringTrim'), array('name' => 'Digits')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập quỹ thu'))), array('name' => 'InArray', 'break_chain_on_failure' => true, 'options' => array('haystack' => array_keys($accountId->getValueOptions()), 'messages' => array('notInArray' => 'Bạn chưa nhập quỹ thu'))))));
$items = new Hidden('items');
$this->add($items);
$filter->add(array('name' => 'items', 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập chi tiết các khoản thu'))))));
$this->add(array('name' => 'afterSubmit', 'type' => 'radio', 'attributes' => array('value' => '/accounting/transaction/addreqrecieve'), 'options' => array('layout' => 'fluid', 'clearBefore' => true, 'label' => 'Sau khi lưu dữ liệu:', 'value_options' => array('/accounting/transaction/addreqrecieve' => 'Tiếp tục nhập', '/accounting/transaction/index' => 'Hiện danh sách vừa nhập'))));
$this->add(array('name' => 'btnSubmit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'button', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary')));
}
示例6: showFilter
/**
* returns a input element for the inline filter
*
* @param $elementName
* @return string|\Zend\Form\ElementInterface
*/
public function showFilter($elementName)
{
$select = new Select($elementName);
$select->setEmptyOption('');
$select->setValueOptions(array('0' => $this->view->translate('no'), '1' => $this->view->translate('yes')));
return $select;
}
示例7: __construct
public function __construct(EntityManager $em, $name = null, $options = array())
{
$this->em = $em;
parent::__construct('BankDetailsForm');
$this->setAttribute('method', 'post');
$this->setAttribute('class', 'form-horizontal');
$city = new Element\Select('cityId');
$city->setLabel('city');
$city->setValueOptions($this->getOptionCity());
$city->setAttribute("class", "dropDnInput");
$city->setAttribute("id", "cityId");
$city->setDisableInArrayValidator(true);
$this->add($city);
$bankName = new Element\Select('bankName');
$bankName->setLabel('Bank Name');
$bankName->setValueOptions($this->getOptionBankNames());
$bankName->setAttribute("class", "dropDnInput");
$this->add($bankName);
$this->add(array('name' => 'branchName', 'attributes' => array('type' => 'text', 'placeholder' => 'Branch Name', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'ifscCode', 'attributes' => array('type' => 'text', 'placeholder' => 'IFSC code', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'save', 'attributes' => array('type' => 'submit', 'value' => 'Submit', 'class' => "btn-blue")));
// $this->add(array(
// 'name' => 'cancel',
// 'attributes' => array(
// 'type' => 'cancel',
// 'value' => 'Cancel',
// 'class' => 'btn btn-primary',
// ),
// 'options' => array(
// 'label' => 'Cancel'
// ),
// ));
}
示例8: Input
function __construct()
{
parent::__construct('console_address');
$element_id = new Element\Hidden('id');
$element_id->setValue('');
$this->add($element_id);
$this->add(array('name' => 'username', 'type' => 'Text'));
$this->add(array('name' => 'domain', 'type' => 'Text'));
$this->add(array('name' => 'nickname', 'type' => 'Text'));
$element_sex = new Element\Select('sex');
$element_sex->setValueOptions(array(self::ADDRESS_SEX_BOY => '男性', self::ADDRESS_SEX_GIRL => '女性'));
$this->add($element_sex);
$this->add(array('name' => 'submit', 'type' => 'Submit'));
/**
* Setting up inputFilter
*/
$input_id = new Input('id');
$input_id->setRequired(false)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 50)))->attach(new \Zend\Validator\Digits());
$input_username = new Input('username');
$input_username->setRequired(true)->getValidatorChain()->attach(new \Zend\Validator\StringLength(array('max' => 18)))->attach(new \Zend\Validator\Digits());
$input_filter = new InputFilter();
$input_filter->add($input_id);
$input_filter->add($input_username);
$this->setInputFilter($input_filter);
}
示例9: __construct
/**
* @author KienNN
* @param unknown $serviceLocator
* @param string $options
*/
public function __construct($serviceLocator, $options = null)
{
parent::__construct();
$this->setServiceLocator($serviceLocator);
$this->setAttribute('method', 'GET');
$filter = $this->getInputFilter();
$filter = $this->getInputFilter();
$daterangepicker = new Text('daterangepicker');
$daterangepicker->setAttributes(['class' => 'date-range-picker']);
$this->add($daterangepicker);
$filter->add(array('name' => 'daterangepicker', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
if ($options && isset($options['displayMode']) && $options['displayMode']) {
$displayMode = new Select('displayMode');
if (is_array($options['displayMode'])) {
$displayMode->setValueOptions($options['displayMode']);
} else {
$displayMode->setValueOptions(array('day' => 'Theo ngày', 'month' => 'Theo tháng'));
}
$this->add($displayMode);
$filter->add(array('name' => 'displayMode', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
}
$companyId = $this->addElementCompany('companyId', null, ['required' => false]);
$departmentId = new Select('departmentId');
$departmentId->setValueOptions(['' => '- Phòng ban -']);
$this->add($departmentId);
$this->loadDepartments($departmentId, $companyId);
$filter->add(array('name' => 'departmentId', 'required' => false, 'filters' => array(array('name' => 'StringTrim'))));
}
示例10: __invoke
public function __invoke($id)
{
$html = "";
$auth = $this->sm->get('ZfcRbac\\Service\\AuthorizationService');
$zfcuserauth = $this->sm->get('zfcuser_auth_service');
$objectmanager = $this->sm->get('Doctrine\\ORM\\EntityManager');
$type = $objectmanager->getRepository('Application\\Entity\\OpSupType')->find($id);
if ($zfcuserauth->hasIdentity()) {
$criteria = array();
$criteria['organisation'] = $zfcuserauth->getIdentity()->getOrganisation()->getId();
$criteria['type'] = $id;
$query = $objectmanager->createQueryBuilder();
$query->select('o')->from('Application\\Entity\\OperationalSupervisor', 'o')->where('o.type = ?1')->groupBy('o.zone')->setParameter(1, $id);
if ($zfcuserauth->getIdentity()->getZone()) {
$query->andWhere($query->expr()->eq('o.zone', '?2'))->setParameter(2, $zfcuserauth->getIdentity()->getZone()->getId());
}
$zones = $query->getQuery()->getResult();
foreach ($zones as $result) {
$criteria['zone'] = $result->getZone()->getId();
$zoneid = $result->getZone()->getId();
$opsups = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findBy($criteria, array('name' => 'asc'));
$currentopsup = $objectmanager->getRepository('Application\\Entity\\OperationalSupervisor')->findOneBy(array('organisation' => $zfcuserauth->getIdentity()->getOrganisation()->getId(), 'zone' => $result->getZone()->getId(), 'type' => $id, 'current' => true));
if ($auth->isGranted('events.mod-opsup')) {
$form = new Form();
$selectOpSup = new Select('nameopsup');
$opsupArray = array();
$opsupArray['-1'] = "Choisir Op Sup";
foreach ($opsups as $opsup) {
$opsupArray[$opsup->getId()] = $opsup->getName();
}
$selectOpSup->setValueOptions($opsupArray);
if ($currentopsup) {
$selectOpSup->setAttribute('value', $currentopsup->getId());
}
$form->add($selectOpSup);
$formView = $this->view->form();
$form->setAttributes(array('class' => 'navbar-form navbar-left opsup-form type-' . $id . ' zone-' . $zoneid, 'data-typeid' => $id, 'data-zoneid' => $zoneid));
$html .= $formView->openTag($form);
$html .= '<div class="form-group">';
$html .= '<label for="nameopsup">';
$html .= ' <span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> <b>' . $type->getName() . (count($zones) > 1 ? ' (' . $result->getZone()->getShortname() . ')' : '') . ' : </b>';
$html .= '<b class="caret"></b></label>';
$html .= $this->view->formSelect($form->get('nameopsup')->setAttribute('class', 'form-control'));
$html .= '</div>';
$html .= $formView->closeTag();
} else {
if ($currentopsup) {
$html .= '<p class="navbar-text navbar-left opsup-name type-' . $id . ' zone-' . $zoneid . '" style="margin-left: 0px"' . ' data-typeid="' . $id . '" data-zoneid="' . $zoneid . '">' . '<span class="glyphicon glyphicon-eye-open" aria-hidden="true"></span> <b>' . $type->getName() . (count($zones) > 1 ? ' (' . $result->getZone()->getShortname() . ')' : '') . ' : </b>' . '<span class="opsupname">' . $currentopsup->getName() . '</span><b class="caret"></b></p>';
} else {
$html .= '<p class="navbar-text navbar-left" style="margin-left: 0px"><em>Aucun Op Sup configuré</em></p>';
}
}
}
} else {
$html .= '<p class="navbar-text navbar-left"><em>Connexion nécessaire</em></p>';
}
return $html;
}
示例11: listAction
/**
* Initially loaded to display the list page's template
* @return ViewModel
*/
public function listAction()
{
$categoryTree = $this->getServiceLocator()->get('category-tree');
$selectCategoryElement = new Select('filter_category');
$selectCategoryElement->setAttribute('id', 'filter_category');
$selectCategoryElement->setEmptyOption($this->translator->translate('All categories'));
$selectCategoryElement->setValueOptions($categoryTree->getSelectOptions());
return new ViewModel(['selectCategory' => $selectCategoryElement, 'locale' => $this->translator->getLocale()]);
}
示例12: thumbnailTypeSelect
/**
* Return a thumbnail type select element.
*
* @param PhpRenderer $view
* @param SiteRepresentation $site
* @param SiteBlockAttachmentRepresentation|null $block
* @return string
*/
public function thumbnailTypeSelect(PhpRenderer $view, SiteRepresentation $site, SitePageBlockRepresentation $block = null)
{
$types = $this->getServiceLocator()->get('Omeka\\File\\Manager')->getThumbnailTypes();
$type = null;
if ($block) {
$type = $this->getData($block->data(), 'thumbnail_type');
}
$select = new Select('o:block[__blockIndex__][o:data][thumbnail_type]');
$select->setValueOptions(array_combine($types, $types))->setValue($type);
return '<label class="thumbnail-option">Thumbnail Type ' . $view->formSelect($select) . '</label>';
}
示例13: __construct
public function __construct(EntityManager $em, $name = null, $options = array())
{
$this->em = $em;
parent::__construct('CityForm');
$this->setAttribute('method', 'post');
$this->setAttribute('enctype', 'multipart/form-data');
$this->setAttribute('class', 'form-horizontal');
$this->add(array('name' => 'ctname', 'attributes' => array('type' => 'text', 'placeholder' => 'City name', 'class' => 'commonDropDnInput')));
$stid = new Element\Select('stid');
$stid->setLabel('State name');
$stid->setAttributes(array('id' => 'stid'));
$stid->setValueOptions($this->getOptionState());
$stid->setAttribute("class", "dropDnInput");
$this->add($stid);
$ctcatid = new Element\Select('ctcatid');
$ctcatid->setLabel('City category');
$ctcatid->setValueOptions($this->getOptionCityCat());
$ctcatid->setAttribute("class", "dropDnInput");
$this->add($ctcatid);
$ctdescription = new Element\Textarea('ctdescription');
$ctdescription->setLabel('City Description');
$ctdescription->setAttribute("class", "selectAreaInput");
$ctdescription->setAttribute("rows", "4");
$ctdescription->setAttribute("cols", "50");
$this->add($ctdescription);
$ctspecialInstructions = new Element\Textarea('ctspecialInstructions');
$ctspecialInstructions->setLabel('City Special Instruction Description');
$ctspecialInstructions->setAttribute("class", "selectAreaInput");
$ctspecialInstructions->setAttribute("rows", "4");
$ctspecialInstructions->setAttribute("cols", "33");
$this->add($ctspecialInstructions);
$ctbestSeasonToVisit = new Element\Textarea('ctbestSeasonToVisit');
$ctbestSeasonToVisit->setLabel('City Best Season to visit');
$ctbestSeasonToVisit->setAttribute("class", "selectAreaInput");
$ctbestSeasonToVisit->setAttribute("rows", "4");
$ctbestSeasonToVisit->setAttribute("cols", "43");
$this->add($ctbestSeasonToVisit);
$this->add(array('name' => 'ctlatitude', 'attributes' => array('type' => 'text', 'placeholder' => 'City Lattitude', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'ctlongitude', 'attributes' => array('type' => 'text', 'placeholder' => 'City Longitude', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'cityPhoto', 'attributes' => array('type' => 'file'), 'options' => array('label' => 'File Upload')));
$this->add(array('name' => 'save', 'attributes' => array('type' => 'submit', 'value' => 'Submit', 'class' => "btn-blue")));
// $this->add(array(
// 'name' => 'cancel',
// 'attributes' => array(
// 'type' => 'cancel',
// 'value' => 'Cancel',
// 'class' => 'btn btn-primary',
// ),
// 'options' => array(
// 'label' => 'Cancel'
// ),
// ));
}
示例14: testInArrayValidationOfOptions
/**
* @dataProvider selectOptionsDataProvider
*/
public function testInArrayValidationOfOptions($valueTests, $options)
{
$element = new SelectElement('my-select');
$element->setValueOptions($options);
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('validators', $inputSpec);
$inArrayValidator = $inputSpec['validators'][0];
$this->assertInstanceOf('Zend\\Validator\\InArray', $inArrayValidator);
foreach ($valueTests as $valueToTest) {
$this->assertTrue($inArrayValidator->isValid($valueToTest));
}
}
示例15: addElements
public function addElements()
{
$this->setAttribute('method', 'post');
$this->add(array('name' => 'id', 'attributes' => array('type' => 'hidden')));
$element = new Element\Text('name');
$element->setAttributes(array('class' => 'name', 'size' => '30', 'class' => 'form-control', 'placeholder' => 'name'));
$this->add($element);
$element = new Element\Select('parent_id');
$element->setAttributes(array('class' => 'form-control ', 'placeholder' => 'parent'));
$element->setValueOptions(array(0 => 'Main'));
$this->add($element);
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Send', 'id' => 'submitbutton', 'class' => 'form-control btn btn-primary')));
}