public function setOptions($options) { parent::setOptions($options); if (isset($this->options['menu_id'])) { $this->setMenuId($this->options['menu_id']); } }
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); }
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); }
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"))); } }
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); }
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'); } }
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); }
/** * 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); }
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); }
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'))); }
/** * 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); }
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); }
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); }
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); }
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')); }
/** * @param array|\Traversable $options * @return self */ public function setOptions($options) { $this->getProxy()->setOptions($options); return parent::setOptions($options); }
public function __construct($name = null) { parent::__construct('contacts'); $id_hidden = new Element\Hidden('id'); $id_hidden->setName('id'); $contacts_select = new Element\Select('contacts'); $contacts_select->setLabel('Contacts'); $contacts_select->setLabelAttributes(array('class' => 'select f_3_w50')); $contacts_select->setAttributes(array('class' => 'sel_chosen')); $contacts_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your link', 'required' => false)); $this->add($id_hidden); $this->add($contacts_select); $this->add(array('type' => 'Profile\\Form\\LinksFieldset')); }
public function __construct($name = null) { parent::__construct('services'); $id_hidden = new Element\Hidden('id'); $id_hidden->setName('id'); $tutorial_select = new Element\Select('tutorial_status'); $tutorial_select->setLabel('Tutorial status'); $tutorial_select->setLabelAttributes(array('class' => 'select f_3_w50')); $tutorial_select->setAttributes(array('class' => 'sel_chosen')); $tutorial_select->setOptions(array('disable_inarray_validator' => true, 'empty_option' => 'Please choose your status')); $members_select = new Element\Textarea('members_special'); $members_select->setLabel('Members Special'); $members_select->setLabelAttributes(array('class' => 'type_text')); $members_select->setAttributes(array('class' => 'type_text_input')); $this->add($id_hidden); $this->add($tutorial_select); $this->add($members_select); $this->add(array('type' => 'Profile\\Form\\AdressesFieldset')); }