本文整理汇总了PHP中Zend\Form\Element\Select::setAttribute方法的典型用法代码示例。如果您正苦于以下问题:PHP Select::setAttribute方法的具体用法?PHP Select::setAttribute怎么用?PHP Select::setAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Form\Element\Select
的用法示例。
在下文中一共展示了Select::setAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __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'
// ),
// ));
}
示例2: __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);
}
示例3: init
/**
* Init Module form
*
* @return void
*/
public function init()
{
$this->setAttribute('class', 'relative');
$fileInfo = new Info();
$modulesInfos = array();
$options = array('' => 'Select an option');
foreach ($this->getServiceLocator()->get('ModulesList') as $path => $dir) {
$options[$dir] = $dir;
$configFile = $path . '/module.info';
if ($fileInfo->fromFile($configFile) === true) {
$modulesInfos[$dir] = $fileInfo->render();
}
}
$collection = new ModuleCollection();
$modules = $collection->getModules();
foreach ($modules as $module) {
if (in_array($module->getName(), $options)) {
unset($options[$module->getName()]);
unset($modulesInfos[$module->getName()]);
}
}
$module = new Element\Select('module');
$module->setLabel('Module')->setLabelAttributes(array('class' => 'required'));
$module->setAttribute('id', 'module')->setAttribute('class', 'form-control')->setAttribute('modules_info', $modulesInfos)->setValueOptions($options);
$this->add($module);
$inputFilterFactory = new InputFilterFactory();
$inputFilter = $inputFilterFactory->createInputFilter(array('module' => array('name' => 'module', 'required' => true, 'validators' => array(array('name' => 'not_empty')))));
$this->setInputFilter($inputFilter);
}
示例4: __construct
public function __construct()
{
parent::__construct('page');
//Méthode d'envoie (GET,POST)
$this->setAttribute('method', 'post');
//Définition des champs
//Menu Page
// $idField = new Element\Select('menu_id');
// $idField->setAttribute('class', 'browser-default');
// $idField->setLabel('Menu');
// $this->add($idField);
$idField = new Element\Hidden('structure');
$idField->setAttribute('id', 'structureform');
$this->add($idField);
$idField = new Element\Hidden('block_element');
$idField->setAttribute('id', 'block-element');
$this->add($idField);
//Page Category
$idField = new Element\Select('ctgr_id');
$idField->setAttribute('class', 'browser-default');
$idField->setLabel('Category');
$this->add($idField);
//Page Title
$titleField = new Element\Text('title');
$titleField->setLabel('Titre');
$this->add($titleField);
//Page Content
$contentField = new Element\Textarea('content');
$contentField->setLabel('Description');
$this->add($contentField);
$submitField = new Element\Submit('submit');
$submitField->setValue('Envoyer');
$submitField->setAttributes(array('id' => 'submitbutton', 'class' => 'btn waves-effect waves-light btn-submit-form-page'));
$this->add($submitField);
}
示例5: init
public function init()
{
$uom = new Select('uom');
$uom->setAttribute('id', 'uom');
$uom->setAttribute('title', $this->translator->translate('web.form.article.uom.title'));
$uom->setAttribute('class', 'form-control');
$uom->setEmptyOption($this->translator->translate('web.form.article.uom.emptyOption'));
$uom->setValueOptions($this->getUomValues());
$uom->setLabel($this->translator->translate('web.form.article.uom.label'));
$this->add($uom);
$name = new Text('name');
$name->setAttribute('id', 'name');
$name->setAttribute('title', $this->translator->translate('web.form.article.name.title'));
$name->setAttribute('class', 'form-control');
$name->setAttribute('placeholder', $this->translator->translate('web.form.article.name.placeholder'));
$name->setLabel($this->translator->translate('web.form.article.name.label'));
$this->add($name);
$code = new Text('code');
$code->setAttribute('id', 'code');
$code->setAttribute('title', $this->translator->translate('web.form.article.code.title'));
$code->setAttribute('class', 'form-control');
$code->setAttribute('placeholder', $this->translator->translate('web.form.article.code.placeholder'));
$code->setLabel($this->translator->translate('web.form.article.code.label'));
$this->add($code);
$salesPrice = new Text('salesPrice');
$salesPrice->setAttribute('id', 'salesPrice');
$salesPrice->setAttribute('class', 'form-control');
$salesPrice->setAttribute('title', $this->translator->translate('web.form.article.salesPrice.title'));
$salesPrice->setAttribute('placeholder', $this->translator->translate('web.form.article.salesPrice.placeholder'));
$salesPrice->setLabel($this->translator->translate('web.form.article.salesPrice.label'));
$this->add($salesPrice);
$qty = new Text('qty');
$qty->setAttribute('id', 'qty');
$qty->setAttribute('class', 'form-control');
$qty->setAttribute('title', $this->translator->translate('web.form.article.qty.title'));
$qty->setAttribute('placeholder', $this->translator->translate('web.form.article.qty.placeholder'));
$qty->setLabel($this->translator->translate('web.form.article.qty.label'));
$this->add($qty);
$description = new Text('description');
$description->setAttribute('id', 'description');
$description->setAttribute('title', $this->translator->translate('web.form.article.description.title'));
$description->setAttribute('class', 'form-control');
$description->setAttribute('placeholder', $this->translator->translate('web.form.article.description.placeholder'));
$description->setLabel($this->translator->translate('web.form.article.description.label'));
$this->add($description);
return $this;
}
示例6: lang
/**
* Language form
*
* @param array $config Configuration
*
* @return void
*/
public function lang($config)
{
$lang = new Element\Select('lang');
$lang->setAttribute('size', 10)->setValueOptions($config['locales'])->setValue('en_GB')->setAttribute('class', 'form-control');
$inputFilter = $this->getInputFilter();
$inputFilter->add(array('name' => 'lang', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'lang');
$this->add($lang);
}
示例7: __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;
}
示例8: 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()]);
}
示例9: 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")));
}
}
示例10: __construct
public function __construct($name = null)
{
parent::__construct('selectAccountForm');
$this->setAttribute('method', 'post');
$selectTipo = new Element\Select('TIPO');
$selectTipo->setLabel('Seleccionar tipo de usuario: ');
$selectTipo->setAttribute('id', 'selectAccountType');
$this->add($selectTipo);
$this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Go', 'id' => 'submitbutton', 'class' => 'btn btn-inverse')));
}
示例11: __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'
// ),
// ));
}
示例12: __construct
public function __construct($name = NULL)
{
parent::__construct($name);
$this->setAttribute('method', 'post');
$this->setAttribute('class', 'form-signin');
$this->add(array('name' => 'search', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'placeholder' => 'Ejem: Restaurantes', 'class' => 'search-query')));
$this->add(array('name' => 'ciudad', 'options' => array('label' => ''), 'attributes' => array('type' => 'text', 'placeholder' => 'Ejem: Xalapa', 'class' => 'search-query')));
$ciudad = new Element\Select('ciudad2');
$ciudad->setLabel("Ciudad:");
$ciudad->setAttribute('class', 'search-query');
$this->add($ciudad);
}
示例13: testProvidesInputSpecificationForSingleSelect
public function testProvidesInputSpecificationForSingleSelect()
{
$element = new SelectElement();
$element->setAttribute('options', array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3'));
$inputSpec = $element->getInputSpecification();
$this->assertArrayHasKey('validators', $inputSpec);
$this->assertInternalType('array', $inputSpec['validators']);
$expectedClasses = array('Zend\\Validator\\InArray');
foreach ($inputSpec['validators'] as $validator) {
$class = get_class($validator);
$this->assertTrue(in_array($class, $expectedClasses), $class);
}
}
示例14: addSelect
protected function addSelect($name, $label, array $values)
{
$select = new Element\Select($name);
$select->setLabel($label);
$select->setLabelAttributes(array('class' => "col-sm-{$this->labelWidth}"));
$select->setOption('column-size', "sm-{$this->controlWidth}");
$select->setValueOptions($values);
if ($this->compact) {
$select->setAttribute('class', 'input-sm');
}
$this->add($select);
return $this;
}
示例15: __construct
public function __construct(EntityManager $em, $name = null, $options = array())
{
$this->em = $em;
parent::__construct('StateForm');
$this->setAttribute('method', 'post');
$this->setAttribute('enctype', 'multipart/form-data');
$this->setAttribute('class', 'form-horizontal');
$country = new Element\Select('cntryId');
$country->setLabel('Country name');
$country->setValueOptions($this->getOptionCountry());
$country->setAttribute("class", "dropDnInput");
$this->add($country);
$this->add(array('name' => 'stname', 'attributes' => array('type' => 'text', 'placeholder' => 'State name', 'class' => 'commonDropDnInput')));
$cntrydescription = new Element\Textarea('statedescription');
$cntrydescription->setLabel('State Description');
$cntrydescription->setAttribute("class", "selectAreaInput");
$cntrydescription->setAttribute("rows", "4");
$cntrydescription->setAttribute("cols", "50");
$this->add($cntrydescription);
$cntryspecialInstructions = new Element\Textarea('statespecialInstructions');
$cntryspecialInstructions->setLabel('State Special Instruction Description');
$cntryspecialInstructions->setAttribute("class", "selectAreaInput");
$cntryspecialInstructions->setAttribute("rows", "4");
$cntryspecialInstructions->setAttribute("cols", "50");
$this->add($cntryspecialInstructions);
$cntrybestSeasonToVisit = new Element\Textarea('statebestSeasonToVisit');
$cntrybestSeasonToVisit->setLabel('State Best Season to visit');
$cntrybestSeasonToVisit->setAttribute("class", "selectAreaInput");
$cntrybestSeasonToVisit->setAttribute("rows", "4");
$cntrybestSeasonToVisit->setAttribute("cols", "50");
$this->add($cntrybestSeasonToVisit);
$this->add(array('name' => 'latitude', 'attributes' => array('type' => 'text', 'placeholder' => 'State Lattitude', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'longitude', 'attributes' => array('type' => 'text', 'placeholder' => 'State Longitude', 'class' => 'commonDropDnInput')));
$this->add(array('name' => 'statePhoto', 'attributes' => array('type' => 'file', 'allowEmpty' => False), 'options' => array('label' => 'File Upload')));
//
// File Input
$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'
// ),
// ));
}