当前位置: 首页>>代码示例>>PHP>>正文


PHP Select::setOptions方法代码示例

本文整理汇总了PHP中Zend\Form\Element\Select::setOptions方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::setOptions方法的具体用法?PHP Select::setOptions怎么用?PHP Select::setOptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\Form\Element\Select的用法示例。


在下文中一共展示了Select::setOptions方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setOptions

 public function setOptions($options)
 {
     parent::setOptions($options);
     if (isset($this->options['menu_id'])) {
         $this->setMenuId($this->options['menu_id']);
     }
 }
开发者ID:uthando-cms,项目名称:uthando-navigation,代码行数:7,代码来源:MenuItemList.php

示例2: __construct

 public function __construct($name = null)
 {
     parent::__construct('usuariosform');
     $this->setAttribute('method', 'post');
     $this->setAttribute('role', 'form');
     $this->setAttributes(array('id' => 'usuariosform'));
     $usuarios_id = new Element('usuarios_id');
     $usuarios_id->setLabel('ID');
     $usuarios_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'usuarios_id', 'readonly' => 'readonly', 'class' => 'form-control'));
     $usuarios_username = new Element('usuarios_username');
     $usuarios_username->setLabel('Usuario');
     $usuarios_username->setAttributes(array('type' => 'text', 'placeholder' => 'dvader', 'id' => 'usuarios_username', 'class' => 'form-control'));
     $usuarios_nombres = new Element('usuarios_nombres');
     $usuarios_nombres->setLabel('Nombre');
     $usuarios_nombres->setAttributes(array('type' => 'text', 'placeholder' => 'Darth Vader', 'id' => 'usuarios_nombres', 'class' => 'form-control'));
     $usuarios_estado = new Element\Select('usuarios_estado');
     $usuarios_estado->setLabel('Estado');
     //$usuarios_estado->setEmptyOption('ELige un Estado..');
     $usuarios_estado->setOptions(array('disable_inarray_validator' => true));
     $usuarios_estado->setAttributes(array('id' => 'usuarios_estado', 'class' => "form-control", 'data-rule-required' => "true", 'data-msg-required' => "Debe seleccionar el Estado"));
     $guardar = new Element\Button('guardar');
     $guardar->setAttributes(array('class' => 'btn btn-success mr5', 'type' => 'submit', 'id' => 'guardar'));
     $guardar->setOptions(array('label' => '<i class="glyphicon glyphicon-floppy-disk"></i>', 'label_options' => array('disable_html_escape' => true)));
     $this->add($usuarios_id);
     $this->add($usuarios_username);
     $this->add($usuarios_nombres);
     $this->add($usuarios_estado);
     $this->add($guardar);
 }
开发者ID:Crisstthian,项目名称:Reminder,代码行数:29,代码来源:UsuariosForm.php

示例3: __construct

 public function __construct($name = null)
 {
     parent::__construct('objetosform');
     $this->setAttribute('method', 'post');
     $this->setAttribute('role', 'form');
     $this->setAttributes(array('id' => 'objetosform'));
     $objetos_actividad_id = new Element('objetos_actividad_id');
     $objetos_actividad_id->setLabel('Actividad');
     $objetos_actividad_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'objetos_actividad_id', 'readonly' => 'readonly', 'class' => 'form-control'));
     $objetos_id = new Element('objetos_id');
     $objetos_id->setLabel('ID');
     $objetos_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'objetos_id', 'readonly' => 'readonly', 'class' => 'form-control'));
     $objetos_nombre = new Element('objetos_nombre');
     $objetos_nombre->setLabel('Nombre');
     $objetos_nombre->setAttributes(array('type' => 'text', 'placeholder' => 'ej: wKER001', 'id' => 'objetos_nombre', 'class' => 'form-control'));
     $objetos_tipo = new Element\Select('objetos_tipo');
     $objetos_tipo->setLabel('Tipo');
     $objetos_tipo->setEmptyOption('Elige un Tipo..');
     $objetos_tipo->setOptions(array('disable_inarray_validator' => true));
     $objetos_tipo->setAttributes(array('id' => 'objetos_tipo', 'class' => "form-control"));
     $guardar = new Element\Button('guardar');
     $guardar->setAttributes(array('class' => 'btn btn-success mr5', 'type' => 'submit', 'id' => 'guardar'));
     $guardar->setOptions(array('label' => '<i class="glyphicon glyphicon-floppy-disk"></i>', 'label_options' => array('disable_html_escape' => true)));
     $etiquetas_id = new Element\Hidden('etiquetas_id');
     $etiquetas_id->setAttributes(array('id' => 'etiquetas_id'));
     $this->add($objetos_actividad_id);
     $this->add($objetos_id);
     $this->add($objetos_nombre);
     $this->add($objetos_tipo);
     $this->add($etiquetas_id);
     $this->add($guardar);
 }
开发者ID:Crisstthian,项目名称:Reminder,代码行数:32,代码来源:ObjetosForm.php

示例4: saveBookAction

 public function saveBookAction()
 {
     if ($this->getAdmin()->getId()) {
         $request = $this->getRequest();
         if ($request->isPost()) {
             $data = $request->getPost()->toArray();
             if ($id = intval($this->params()->fromRoute("id", false))) {
                 $form = new EditBookForm();
             } else {
                 $form = new AddBookForm();
             }
             // get authors form DB
             $authors = array();
             foreach ($this->getAuthorTable()->fetchAll() as $author) {
                 $authors[$author->getId()] = $author->getName();
             }
             $select = new Select('book_author_id');
             $select->setOptions(array('options' => $authors));
             $form->add($select);
             // get genres form DB
             $genres = array();
             foreach ($this->getGenreTable()->fetchAll() as $genre) {
                 $genres[$genre->getId()] = $genre->getName();
             }
             $select = new Select('book_genre_ids');
             $select->setAttribute("multiple", "multiple");
             $select->setOptions(array('options' => $genres));
             $form->add($select);
             if ($id) {
                 $book = $this->getBookTable()->find($id);
             } else {
                 $book = $this->getBookTable()->createNew();
             }
             $form->setInputFilter($book->getInputFilterBookSave(array_keys($authors)));
             $form->setData($data);
             if ($form->isValid()) {
                 $book->exchangeArray($data);
                 $book = $this->getBookTable()->save($book);
                 $result = array("redirectTo" => $this->url()->fromRoute("admin", array("action" => "edit-book", "id" => $book->getId())));
                 if ($id) {
                     $this->getBookTable()->removeGenresFromBook($book->getId());
                     $result = false;
                 }
                 foreach ($data['book_genre_ids'] as $genreId) {
                     $this->getBookTable()->addGenreToBook($genreId, $book->getId());
                 }
                 return new JsonModel(array("returnCode" => 101, "result" => $result, "msg" => "Book Has Been Saved."));
             } else {
                 return new JsonModel(array("returnCode" => 202, "msg" => $form->getMessages()));
             }
         }
         return new JsonModel(array("returnCode" => 201, "msg" => "Wrong request."));
     } else {
         return new JsonModel(array("returnCode" => 201, "msg" => $this->getErrorMsgZendFormat("Your are logged in")));
     }
 }
开发者ID:povtasci,项目名称:zend2Sample,代码行数:56,代码来源:AdminActionController.php

示例5: __construct

 public function __construct($name = null, $options = array())
 {
     parent::__construct(isset($name) ? $name : 'personal');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $firstname_text = new Element\Text('firstname');
     $firstname_text->setLabel('First name');
     $firstname_text->setLabelAttributes(array('class' => 'type_text'));
     $firstname_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...'));
     $lastname_text = new Element\Text('lastname');
     $lastname_text->setLabel('Last name');
     $lastname_text->setLabelAttributes(array('class' => 'type_text'));
     $lastname_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => true));
     $country_select = new Element\Select('country_id');
     $country_select->setLabel('Country');
     $country_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $country_select->setAttributes(array('class' => 'sel_chosen'));
     $country_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your country'));
     $state_select = new Element\Select('state_id');
     $state_select->setLabel('Province/State');
     $state_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $state_select->setAttributes(array('class' => 'sel_chosen', 'required' => true));
     $state_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your state'));
     $city_select = new Element\Select('city_id');
     $city_select->setLabel('City');
     $city_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $city_select->setAttributes(array('class' => 'sel_chosen', 'required' => true));
     $city_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your city'));
     $adress_text = new Element\Text('adress');
     $adress_text->setLabel('Adress');
     $adress_text->setLabelAttributes(array('class' => 'type_text'));
     $adress_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type adress in format (наш формат)'));
     $languages_select = new Element\Select('languages');
     $languages_select->setLabel('Languages');
     $languages_select->setLabelAttributes(array('class' => 'select', 'style' => 'float:left;'));
     $languages_select->setAttributes(array('class' => 'sel_chosen', 'multiple' => 'multiple', 'required' => true));
     $languages_select->setOptions(array('disable_inarray_validator' => true));
     $logo = new Element\Image('logo');
     $logo->setAttributes(array('src', '/images/11.jpg', 'style' => 'float:left;'));
     $file = new Element\File('file');
     $file->setLabelAttributes(array('style' => 'float:left;clear:both'));
     $this->add($id_hidden);
     $this->add($firstname_text);
     $this->add($lastname_text);
     $this->add($country_select);
     $this->add($state_select);
     $this->add($city_select);
     $this->add($adress_text);
     $this->add($languages_select);
     $this->add($logo);
     $this->add($file);
 }
开发者ID:KukaBazuka,项目名称:zendy,代码行数:52,代码来源:PersonalForm.php

示例6: setOptions

 public function setOptions($options)
 {
     parent::setOptions($options);
     if (null == $this->getLabel()) {
         $this->setLabel('Status');
     }
     if (!isset($this->options['description'])) {
         $this->options['description'] = 'Select a job status.';
     }
     if (null == $this->getName()) {
         $this->setName('status');
     }
 }
开发者ID:cross-solution,项目名称:yawik,代码行数:13,代码来源:StatusSelect.php

示例7: initUsersSelect

 public function initUsersSelect($currentUser = null)
 {
     $users = $this->userTable->fetchAll();
     foreach ($users as $user) {
         if ($user->getEmail() != $currentUser->getEmail()) {
             $usersOptions[$user->getId()] = $user->getEmail();
         }
     }
     $options = array('label' => 'Send to', 'value_options' => $usersOptions, 'disable_inarray_validator' => true, "attributes" => array("value" => 0));
     $select = new Element\Select('user');
     $select->setOptions($options);
     $this->add($select);
 }
开发者ID:seyfer,项目名称:zend2-tutorial.me,代码行数:13,代码来源:SendMailForm.php

示例8: load

 /**
  * Load Textarea prevalue editor
  * - cols:   Number of caracters display per line
  * - rows:   Define the number of line visible in text zone
  * - wrap:   Possible values are : hard / off / soft
  *                       define if line returns are automatic (hard / soft)
  *                       or if the horizontal display if exceeded (off)
  *
  * @return mixed
  */
 public function load()
 {
     $config = $this->getConfig();
     $cols = new Element\Text('cols');
     $cols->setAttributes(array('value' => isset($config['cols']) ? $config['cols'] : '', 'class' => 'form-control'));
     $cols->setOptions(array('label' => 'Cols', 'label_attributes' => array('class' => 'required control-label col-lg-2')));
     $rows = new Element\Text('rows');
     $rows->setAttributes(array('value' => isset($config['rows']) ? $config['rows'] : '', 'class' => 'form-control'));
     $rows->setOptions(array('label' => 'Rows', 'label_attributes' => array('class' => 'required control-label col-lg-2')));
     $wrap = new Element\Select('wrap');
     $wrap->setAttributes(array('class' => 'form-control', 'options' => array('hard' => 'hard', 'off' => 'off', 'soft' => 'soft'), 'value' => isset($config['wrap']) ? $config['wrap'] : ''));
     $wrap->setOptions(array('label' => 'Wrap', 'label_attributes' => array('class' => 'required control-label col-lg-2')));
     return array($cols, $rows, $wrap);
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:24,代码来源:PrevalueEditor.php

示例9: __construct

 public function __construct($name = null)
 {
     parent::__construct('actividadesform');
     $this->setAttribute('method', 'post');
     $this->setAttribute('role', 'form');
     $this->setAttributes(array('id' => 'actividadesform'));
     $actividades_id = new Element('actividades_id');
     $actividades_id->setLabel('ID');
     $actividades_id->setAttributes(array('type' => 'text', 'placeholder' => 'Este campo se genera automáticamente', 'id' => 'actividades_id', 'readonly' => 'readonly', 'class' => 'form-control'));
     $actividades_nombre = new Element('actividades_nombre');
     $actividades_nombre->setLabel('Nombre');
     $actividades_nombre->setAttributes(array('type' => 'text', 'placeholder' => 'ej: Mi Primera Actividad', 'id' => 'actividades_nombre', 'class' => 'form-control'));
     $actividades_estado = new Element\Select('actividades_estado');
     $actividades_estado->setLabel('Estado');
     //$actividades_estado->setEmptyOption('ELige un Estado..');
     $actividades_estado->setOptions(array('disable_inarray_validator' => true));
     $actividades_estado->setAttributes(array('id' => 'actividades_estado', 'class' => "form-control", 'data-rule-required' => "true", 'data-msg-required' => "Debe seleccionar el Estado"));
     $actividades_responsable = new Element\Select('actividades_responsable');
     $actividades_responsable->setLabel('Responsable');
     // $actividades_responsable->setEmptyOption('Elige un Responsable..');
     $actividades_responsable->setOptions(array('disable_inarray_validator' => true));
     $actividades_responsable->setAttributes(array('id' => 'actividades_responsable', 'class' => "form-control"));
     $actividades_area = new Element\Select('actividades_area');
     $actividades_area->setLabel('Área');
     $actividades_area->setEmptyOption('Elige una Área..');
     $actividades_area->setOptions(array('disable_inarray_validator' => true));
     $actividades_area->setAttributes(array('id' => 'actividades_area', 'class' => "form-control"));
     $actividades_reporta = new Element('actividades_reporta');
     $actividades_reporta->setLabel('Reportada Por');
     $actividades_reporta->setAttributes(array('type' => 'text', 'placeholder' => 'Persona que reporta', 'id' => 'actividades_reporta', 'class' => 'form-control'));
     $actividades_fecha = new Element('actividades_fecha');
     $actividades_fecha->setLabel('Fecha de Inicio');
     $actividades_fecha->setAttributes(array('placeholder' => 'Fecha de Inicio', 'id' => 'actividades_fecha', 'class' => 'form-control'));
     $actividades_fecha_fin = new Element('actividades_fecha_fin');
     $actividades_fecha_fin->setLabel('Fecha de Finalización');
     $actividades_fecha_fin->setAttributes(array('placeholder' => 'Fecha de Finalización', 'id' => 'actividades_fecha_fin', 'class' => 'form-control'));
     $guardar = new Element\Button('guardar');
     $guardar->setAttributes(array('class' => 'btn btn-success mr5', 'type' => 'submit', 'id' => 'guardar'));
     $guardar->setOptions(array('label' => '<i class="glyphicon glyphicon-floppy-disk"></i>', 'label_options' => array('disable_html_escape' => true)));
     $this->add($actividades_id);
     $this->add($actividades_nombre);
     $this->add($actividades_fecha);
     $this->add($actividades_estado);
     $this->add($actividades_responsable);
     $this->add($actividades_area);
     $this->add($actividades_reporta);
     $this->add($actividades_fecha_fin);
     $this->add($guardar);
 }
开发者ID:Crisstthian,项目名称:Reminder,代码行数:49,代码来源:ActividadesForm.php

示例10: __construct

 public function __construct($name = null)
 {
     parent::__construct('add-book');
     $this->setAttribute('method', 'post');
     $this->add(array('name' => 'book_title', 'attributes' => array('type' => 'text')));
     $this->add(array('name' => 'book_description', 'attributes' => array('type' => 'text')));
     $textarea = new Textarea('book_description');
     $textarea->setLabel('Short Description');
     $this->add($textarea);
     $this->add(array('name' => 'book_image', 'attributes' => array('type' => 'hidden')));
     $this->add(array('name' => 'book_pdf', 'attributes' => array('type' => 'hidden')));
     $this->add(array('name' => 'book_status', 'attributes' => array('type' => 'hidden')));
     $select = new Select('book_status');
     $select->setLabel('Status');
     $select->setOptions(array('options' => array('active' => 'Active', 'inactive' => 'Inactive', 'pending' => 'Pending')));
     $this->add($select);
     $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit')));
 }
开发者ID:povtasci,项目名称:zend2Sample,代码行数:18,代码来源:AddBookForm.php

示例11: init

 /**
  * Init Datatype form
  *
  * @return void
  */
 public function init()
 {
     $this->setAttribute('class', 'relative form-horizontal');
     $this->setAttribute('enctype', 'application/x-www-form-urlencoded');
     $name = new Element\Text('name');
     $name->setLabel('Name')->setLabelAttributes(array('class' => 'required control-label col-lg-2'));
     $name->setAttribute('class', 'form-control')->setAttribute('id', 'name');
     $this->add($name);
     $model = new Element\Select('model');
     $options = array();
     foreach ($this->getServiceLocator()->get('DatatypesList') as $dir) {
         $options[$dir] = $dir;
     }
     $model->setOptions(array('label' => 'Model', 'label_attributes' => array('class' => 'required control-label col-lg-2')));
     $model->setValueOptions($options)->setAttribute('class', 'form-control');
     $this->add($model);
     $inputFilterFactory = new InputFilterFactory();
     $inputFilter = $inputFilterFactory->createInputFilter(array('name' => array('required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'db\\no_record_exists', 'options' => array('table' => 'datatype', 'field' => 'name', 'adapter' => $this->getAdapter())))), 'model' => array('required' => true, 'validators' => array(array('name' => 'not_empty')))));
     $this->setInputFilter($inputFilter);
 }
开发者ID:gotcms,项目名称:gotcms,代码行数:25,代码来源:Datatype.php

示例12: initSharedUsersSelect

 public function initSharedUsersSelect($uploadId)
 {
     $upload = $this->uploadTable->getById($uploadId);
     $sharedUsers = $this->uploadTable->getSharedUsers($uploadId);
     foreach ($sharedUsers as $sharedUser) {
         $userSelected[] = $sharedUser->user_id;
     }
     //        \Zend\Debug\Debug::dump($sharedUsers);
     $users = $this->userTable->fetchAll();
     foreach ($users as $user) {
         if ($user->getId() != $upload->getUserId()) {
             $usersOptions[$user->getId()] = $user->getEmail();
         }
     }
     $options = array('label' => 'Пользователи', 'value_options' => $usersOptions, 'disable_inarray_validator' => true, "attributes" => array("value" => 0));
     $select = new Element\Select('shared_user_ids');
     $select->setOptions($options);
     $select->setValue($userSelected);
     $select->setAttribute('multiple', 'multiple');
     $this->add($select);
 }
开发者ID:seyfer,项目名称:zend2-tutorial.me,代码行数:21,代码来源:UploadForm.php

示例13: __construct

 public function __construct($name = null)
 {
     parent::__construct('terms');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $orders_radio = new Element\Radio('custom_orders');
     $orders_radio->setLabel('Custom orders');
     $orders_radio->setValueOptions(array('0' => 'No', '1' => 'Yes'));
     $shipping_select = new Element\Select('shipping');
     $shipping_select->setLabel('Shipping');
     $shipping_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $shipping_select->setAttributes(array('class' => 'sel_chosen'));
     $shipping_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your shipping'));
     $policies_text = new Element\Textarea('wholesale_policies');
     $policies_text->setLabel('Wholesale policies');
     $policies_text->setLabelAttributes(array('class' => 'type_text'));
     $policies_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...'));
     $this->add($id_hidden);
     $this->add($orders_radio);
     $this->add($shipping_select);
     $this->add($policies_text);
 }
开发者ID:KukaBazuka,项目名称:zendy,代码行数:22,代码来源:TermsForm.php

示例14: __construct

 public function __construct($name = null, $options = array())
 {
     parent::__construct(isset($name) ? $name : 'about');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $specialty_text = new Element\Text('specialty');
     $specialty_text->setLabel('Specialty');
     $specialty_text->setLabelAttributes(array('class' => 'type_text'));
     $specialty_text->setAttributes(array('class' => 'type_text_input'));
     $proficiency_select = new Element\Select('proficiency_level');
     $proficiency_select->setLabel('Proficiency level');
     $proficiency_select->setLabelAttributes(array('class' => 'select f_3_w50'));
     $proficiency_select->setAttributes(array('class' => 'sel_chosen'));
     $proficiency_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your proficiency'));
     $about_textarea = new Element\Textarea('about');
     $about_textarea->setLabel('About');
     $about_textarea->setLabelAttributes(array('class' => 'type_text'));
     $about_textarea->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => 'require'));
     $this->add($id_hidden);
     $this->add($specialty_text);
     $this->add($proficiency_select);
     $this->add($about_textarea);
 }
开发者ID:KukaBazuka,项目名称:zendy,代码行数:23,代码来源:AboutForm.php

示例15: testSetOptionsOptions

 public function testSetOptionsOptions()
 {
     $element = new SelectElement();
     $element->setOptions(array('value_options' => array('bar' => 'baz'), 'options' => array('foo' => 'bar'), 'empty_option' => array('baz' => 'foo')));
     $this->assertEquals(array('bar' => 'baz'), $element->getOption('value_options'));
     $this->assertEquals(array('foo' => 'bar'), $element->getOption('options'));
     $this->assertEquals(array('baz' => 'foo'), $element->getOption('empty_option'));
 }
开发者ID:rajanlamic,项目名称:IntTest,代码行数:8,代码来源:SelectTest.php


注:本文中的Zend\Form\Element\Select::setOptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。