本文整理汇总了PHP中Zend\Form\Element\Select::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::setAttributes方法的具体用法?PHP Select::setAttributes怎么用?PHP Select::setAttributes使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\Select
的用法示例。
在下文中一共展示了Select::setAttributes方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct($serviceLocator, $options = null)
{
parent::__construct('AccountIndex');
$this->setServiceLocator($serviceLocator);
$this->setAttribute('method', 'post');
$filter = $this->getInputFilter();
$group = new DisplayGroup('Subject');
$group->setLabel('Thêm môn học');
$this->add($group);
// name
$name = new Text('name');
$name->setLabel('Tên môn học:');
$name->setAttributes(['maxlength' => 255]);
$this->add($name);
$group->addElement($name);
$filter->add(array('name' => 'name', '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 tên môn học'))))));
$categoryId = new Select('categoryId');
$categoryId->setLabel('Danh mục:');
$categoryId->setAttributes(['maxlength' => 10]);
$this->add($categoryId);
$this->loadCategories($categoryId, $options);
$group->addElement($categoryId);
$filter->add(array('name' => 'categoryId', 'required' => true, 'validators' => array(array('name' => 'NotEmpty', 'break_chain_on_failure' => true, 'options' => array('messages' => array('isEmpty' => 'Bạn chưa nhập danh mục môn học'))))));
// code
$description = new Textarea('description');
$description->setLabel('Mô tả môn học:');
$description->setAttributes(['maxlength' => 255, 'class' => 'form-control basicEditor ', 'style' => 'min-height: 300px;']);
$this->add($description);
$group->addElement($description);
$filter->add(array('name' => 'description', 'required' => false, '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 mô tả môn học'))))));
$this->add(array('name' => 'afterSubmit', 'type' => 'radio', 'attributes' => array('value' => '/admin/subject/add'), 'options' => array('layout' => 'fluid', 'clearBefore' => true, 'label' => 'Sau khi lưu dữ liệu:', 'value_options' => array('/admin/subject/add' => 'Tiếp tục nhập', '/admin/subject/index' => 'Hiện danh sách vừa nhập'))));
$this->add(array('name' => 'submit', 'options' => array('clearBefore' => true), 'attributes' => array('type' => 'submit', 'value' => 'Lưu', 'id' => 'btnSave', 'class' => 'btn btn-primary')));
}
示例2: getPerfil
public function getPerfil()
{
$element = new Select('perfil');
$element->setLabel('Perfil:');
$element->setAttributes(array('id' => 'perfil', 'class' => 'form-control validar'));
return $element;
}
示例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);
}
示例4: __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);
}
示例5: Select
function __invoke($name, $emptyOption, $value, $selected, array $options = null)
{
$options = $this->setDefaultOptions($options);
$elementSelect = new Select($name);
$elementSelect->setAttributes($options)->setEmptyOption($emptyOption)->setValueOptions($value)->setValue($selected);
return $this->render($elementSelect);
}
示例6: form
public function form(PhpRenderer $view)
{
// Normalize vocab terms for use in a select element.
$terms = array_map('trim', explode(PHP_EOL, $this->vocab->terms()));
$valueOptions = array_combine($terms, $terms);
$select = new Select('customvocab');
$select->setAttributes(['class' => 'terms to-require', 'data-value-key' => '@value'])->setEmptyOption('Select Below')->setValueOptions($valueOptions);
return $view->formSelect($select);
}
示例7: getTemplate
public function getTemplate(PhpRenderer $view)
{
// Normalize vocab terms for use in a select element.
$terms = array_map('trim', explode(PHP_EOL, $this->vocab->terms()));
$valueOptions = array_combine($terms, $terms);
$hidden = new Hidden('customvocab');
$hidden->setAttributes(['class' => 'language'])->setValue($this->vocab->lang());
$select = new Select('customvocab');
$select->setAttributes(['class' => 'terms'])->setEmptyOption('Select Below')->setValueOptions($valueOptions);
return $view->formHidden($hidden) . $view->formSelect($select);
}
示例8: __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'
// ),
// ));
}
示例9: testInArrayValidationOfOptions
/**
* @dataProvider selectOptionsDataProvider
*/
public function testInArrayValidationOfOptions($valueTests, $options)
{
$element = new SelectElement('my-select');
$element->setAttributes(array('options' => $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));
}
}
示例10: __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);
}
示例11: 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')));
}
示例12: 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);
}
示例13: __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);
}
示例14: __construct
public function __construct(EntityManager $em, $name = null, $options = array())
{
$this->em = $em;
parent::__construct('toll');
$this->setAttribute('method', 'post');
$this->add(array('name' => 'tollName', 'attributes' => array('type' => 'text', 'class' => 'commonDropDnInput', 'placeholder' => 'Toll Name')));
$city = new Element\Select('cityId');
$city->setEmptyOption("Select City Name");
$city->setAttributes(array("id" => "cityId"));
$city->setAttributes(array("class" => "dropDnInput"));
// $city->setAttributes(array('onChange'=>'setter("city",this.options[this.selectedIndex].text)','class'=>'dropDnInput'));
$city->setValueOptions($this->getOptionsForSelectCity());
$this->add($city);
$locationId = new Element\Select('locationId');
$locationId->setEmptyOption("Select Location Name");
// $locationId->setAttributes("id","location");
$locationId->setAttributes(array("id" => "location"));
$locationId->setAttributes(array("class" => "dropDnInput"));
// $locationId->setAttributes(array('onChange'=>'setter("city",this.options[this.selectedIndex].text)','class'=>'dropDnInput'));
$locationId->setValueOptions($this->getOptionsForSelectLocation());
$locationId->setDisableInArrayValidator(true);
$this->add($locationId);
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Go', 'id' => 'submitbutton', 'class' => "btn-blue")));
}
示例15: __construct
public function __construct($name = null, $tracks = array())
{
parent::__construct('submission');
$this->setAttribute('method', 'post');
$this->setAttribute('class', 'well offset3 span6');
// You'll see _() functions here. This is for the sake of "extractability" :)
$this->add(array('name' => 'title', 'attributes' => array('type' => 'text', 'class' => 'span'), 'options' => array('label' => _('Title'))));
$track = new Select('track_id', array('label' => _('Track')));
$track->setAttributes(array('class' => 'span', 'options' => $tracks));
$this->add($track);
$this->add(array('name' => 'abstract', 'attributes' => array('type' => 'textarea', 'class' => 'span', 'rows' => '5'), 'options' => array('label' => _('Abstract'))));
$this->add(array('name' => 'minicurriculo', 'attributes' => array('type' => 'textarea', 'class' => 'span', 'rows' => '5'), 'options' => array('label' => _('Mini-curriculo do palestrante'))));
$duration = new Select('duration', array('label' => _('Duration')));
$duration->setAttributes(array('class' => 'span', 'options' => array('1' => '1h', '2' => '2h', '3' => '3h', '4' => '4h+')));
$this->add($duration);
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'id' => 'submitbutton', 'class' => 'btn btn-primary btn-large span', 'value' => _('Submit'))));
}