/** {@inheritdoc} */ public function init() { parent::init(); $translatedTypes = array('text' => $this->_('Text'), 'clob' => $this->_('Long text'), 'integer' => $this->_('Integer'), 'float' => $this->_('Float'), 'date' => $this->_('Date')); $fields = new \Zend\Form\Fieldset('Fields'); $this->add($fields); $inputFilterFields = new \Zend\InputFilter\InputFilter(); foreach ($this->getOption('CustomFieldManager')->getFields() as $name => $type) { if ($name == 'TAG') { // Static field, can not be edited continue; } $this->_definedFields[$name] = $translatedTypes[$type]; $element = new \Zend\Form\Element\Text($name); $element->setValue($name); $fields->add($element); $filter = array('name' => $name, 'required' => true, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('min' => 1, 'max' => 255)), array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateName'), 'callbackOptions' => $name, 'message' => $this->_('The name already exists'))))); $inputFilterFields->add($filter); } // Empty text field to create new field. $newName = new \Zend\Form\Element\Text('NewName'); $newName->setLabel('Add'); $this->add($newName); // Datatype of new field $newType = new \Zend\Form\Element\Select('NewType'); $newType->setValueOptions($translatedTypes); $this->add($newType); $submit = new \Library\Form\Element\Submit('Submit'); $submit->setLabel('Change'); $this->add($submit); $inputFilter = new \Zend\InputFilter\InputFilter(); $inputFilter->add($inputFilterFields, 'Fields'); $inputFilter->add(array('name' => 'NewName', 'required' => false, 'filters' => array(array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => array('max' => 255)), array('name' => 'Callback', 'options' => array('callback' => array($this, 'validateName'), 'message' => $this->_('The name already exists')))))); $this->setInputFilter($inputFilter); }
public function __construct() { parent::__construct(); $this->setAttribute('method', 'POST'); $Controller = new Text('Controller'); $Controller->setLabel("Controller: "); $Controller->setAttributes(array("class" => 'form-control')); $this->add($Controller); $nome = new Text('nome'); $nome->setLabel("Nome: "); $nome->setAttributes(array("class" => 'form-control')); $this->add($nome); $label = new Text('label'); $label->setLabel("Label: "); $label->setAttributes(array("class" => 'form-control')); $this->add($label); $route = new Text('route'); $route->setLabel("Route: "); $route->setAttributes(array("class" => 'form-control')); $this->add($route); $select = new \Zend\Form\Element\Select('parentView'); $select->setLabel('Parente View'); $select->setAttributes(array("class" => 'form-control')); $select->setValueOptions(array('0' => 'French', '1' => 'English', '2' => 'Japanese', '3' => 'Chinese')); $this->add($select); $status = new \Zend\Form\Element\Select('Status'); $status->setLabel('Status'); $status->setAttributes(array("class" => 'form-control')); $status->setValueOptions(array('0' => '', '1' => 'Ativo', '2' => 'Inativo')); $this->add($status); $submit = new \Zend\Form\Element\Submit('Salvar'); $submit->setValue('Salvar')->setAttributes(array("class" => 'btn btn-primary btn-lg btn-block')); $this->add($submit); }
protected function getOutputSelect($name) { $select = new \Zend\Form\Element\Select($name); $select->setAttributes(array('id' => $name)); $select->setLabel('Output Type'); $select->setEmptyOption('-- Select Output Type --'); $opt = array('binary' => 'Binary', 'base64' => 'Base 64 Encoded'); $select->setValueOptions($opt); $select->setValue('base64'); return $select; }
public function __construct($author, $project) { parent::__construct('reference'); $this->add(array('name' => 'name', 'type' => 'text', 'attributes' => array('placeholder' => 'Ticket name'))); $this->add(array('name' => 'desc', 'type' => 'textarea', 'attributes' => array('placeholder' => 'Brief description (optional)'))); $select = new \Zend\Form\Element\Select('importance'); $select->setLabel('Set importance of this ticket'); $select->setValueOptions(array('1' => 'Very low', '2' => 'Low', '3' => 'Medium', '4' => 'High', '5' => 'Very high')); $this->add($select); $this->add(array('name' => 'author_id', 'type' => 'hidden', 'attributes' => array('value' => $author))); $this->add(array('name' => 'project_id', 'type' => 'hidden', 'attributes' => array('value' => $project))); $this->add(array('name' => 'submit', 'attributes' => array('class' => 'hvr-grow'))); }
protected function getKeySizeSelect($name) { $select = new \Zend\Form\Element\Select($name); $select->setAttributes(array('id' => $name)); $select->setLabel('Key Size'); $select->setEmptyOption('-- Select Key Size --'); $opt = array(); for ($pow = 10; $pow <= 13; $pow++) { $v = pow(2, $pow); $opt[$v] = number_format($v) . ' Bytes'; } $select->setValueOptions($opt); $select->setValue(\Zend\Crypt\PublicKey\Rsa\PrivateKey::DEFAULT_KEY_SIZE); return $select; }
public function setKeyStorage(KeyStorageInterface $storage) { parent::setKeyStorage($storage); $this->add($this->getKeyListSelect('keyName')); $this->add(array('name' => 'keyPassPhrase', 'type' => 'password', 'options' => array('label' => 'Pass Phrase'), 'attributes' => array('id' => 'keyPassPhrase', 'title' => 'Provide the password associated with your private key'))); $dir = new \Zend\Form\Element\Select('direction'); $dir->setAttributes(array('id' => 'direction')); $opt = array('encrypt' => 'Encrypt', 'decrypt' => 'Decrypt'); $dir->setValueOptions($opt); $dir->setLabel('Encrypt or Decrypt'); $this->add($dir); $out = $this->getOutputSelect('outputType'); $out->setLabel('Set encrypted output format'); $this->add($out); $this->add(array('name' => 'sourceText', 'type' => 'textarea', 'options' => array('label' => 'Input Text'), 'attributes' => array('id' => 'sourceText'))); $this->add(array('name' => 'processText', 'type' => 'button', 'attributes' => array('id' => 'processText', 'type' => 'submit'), 'options' => array('label' => 'Encrypt/Decrypt'))); }
public function __construct($name = null, $sm) { parent::__construct('MenuForm'); $this->setAttribute('method', 'post'); $this->setAttribute('enctype', 'multipart/form-data'); $menu_id = new \Zend\Form\Element\Hidden('menu_id'); $this->add($menu_id); $menu_name = new \Zend\Form\Element\Text('name', array('label' => 'Menu Name')); $menu_name->setAttributes(array('placeholder' => 'Menu Name...', 'required' => 'required', 'class' => 'form-control', 'min' => 3, 'max' => 50)); $this->add($menu_name); $label = new \Zend\Form\Element\Text('label', array('label' => 'Label')); $label->setAttributes(array('placeholder' => 'Label...', 'required' => 'required', 'class' => 'form-control', 'min' => 3, 'max' => 50)); $this->add($label); $uri = new \Zend\Form\Element\Text('uri', array('label' => 'Uri')); $uri->setAttributes(array('placeholder' => 'Uri...', 'required' => 'required', 'class' => 'form-control', 'min' => 1, 'max' => 50)); $this->add($uri); $route = new \Zend\Form\Element\Text('route', array('label' => 'Route')); $route->setAttributes(array('placeholder' => 'Route...', 'class' => 'form-control', 'max' => 50)); $this->add($route); $parent_menu = new \Zend\Form\Element\Select('parent_menu_id', array('label' => 'Parent Menu')); $parent_menu->setAttributes(array('class' => 'form-control')); $parent_options = array('0' => 'None'); $parentMenus = $sm->get('MenuModel')->fetchParentMenus(); if (0 !== count($parentMenus)) { foreach ($parentMenus as $key => $menu) { $parent_options[$menu->menu_id] = $menu->name; } } unset($parentMenus); $parent_menu->setValueOptions($parent_options); $this->add($parent_menu); $icon = new \Zend\Form\Element\Text('icon', array('label' => 'Icon')); $icon->setAttributes(array('placeholder' => 'Icon...', 'class' => 'form-control', 'max' => 50)); $this->add($icon); $this->add(array('name' => 'submit', 'attributes' => array('type' => 'submit', 'value' => 'Create', 'class' => 'btn btn-primary col-xs-12'))); }
/** * Rendering filters * * @return string */ public function renderFilters() { $headers = $this->getTable()->getHeaders(); $render = ''; foreach ($headers as $name => $params) { if (isset($params['filters'])) { $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name); $id = 'zff_' . $name; if (is_string($params['filters'])) { $element = new \Zend\Form\Element\Text($id); } else { $element = new \Zend\Form\Element\Select($id); $element->setValueOptions($params['filters']); } $element->setAttribute('class', 'filter form-control'); $element->setValue($value); $render .= sprintf('<td>%s</td>', $this->getRenderer()->formRow($element)); } else { $render .= '<td></td>'; } } return sprintf('<tr>%s</tr>', $render); }
/** * Return form element config * @return array * @implements FormElementProviderInterface */ public function getFormElementConfig() { return array('factories' => array('NetgluePrismic\\Form\\Element\\SelectPrismicRef' => function ($manager) { $element = new \Zend\Form\Element\Select('ref'); $services = $manager->getServiceLocator(); $context = $services->get('Prismic\\Context'); $api = $context->getPrismicApi(); $options = array(); foreach ($api->refs() as $ref) { if ($ref->isMasterRef()) { $options[$ref->getRef()] = 'Current Live Website'; } else { $options[$ref->getRef()] = $ref->getLabel(); } } $element->setValueOptions($options); $element->setValue($context->getRefAsString()); return $element; })); }
/** * Rendering filters * * @return string */ public function renderFiltersInHeader() { $headers = $this->getTable()->getHeaders(); $render = ''; foreach ($headers as $name => $params) { if (isset($params['filters'])) { $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name); $id = 'zff_' . $name; if (!isset($params['placeholder'])) { $params['placeholder'] = $params['title']; } if (!is_array($params['filters']) && class_exists($params['filters'])) { $element = new $params['filters']($id); } else { if (is_string($params['filters'])) { $element = new \Zend\Form\Element\Text($id); } else { $element = new \Zend\Form\Element\Select($id); $element->setValueOptions($params['filters']); } } $element->setAttribute('class', 'filter form-control input-sm'); $element->setAttribute('placeholder', $params['placeholder']); $element->setAttribute('data-placeholder', $params['placeholder']); $element->setValue($value); $render .= sprintf('<div class="form-group">%s</div>', $this->getRenderer()->formRow($element)); } else { // $render .= '<div></div>'; } } return sprintf('<div class="form-body">%s</div>', $render); }
/** * Rendering filters * * @return string */ public function renderFilters() { $headers = $this->getTable()->getHeaders(); $render = ''; $options = $this->getTable()->getOptions(); $tableName = strtolower($options->getName()); $session = new Container(); foreach ($headers as $name => $params) { if (isset($params['filters'])) { $value = $this->getTable()->getParamAdapter()->getValueOfFilter($name); $id = 'zff_' . $tableName . '_' . $name; if (is_string($params['filters'])) { $element = new \Zend\Form\Element\Text($id); $element->setAttribute('placeholder', 'Pesquisar ' . strtolower($params['title'])); } else { $element = new \Zend\Form\Element\Select($id); $element->setValueOptions($params['filters']); } $class = ''; if (isset($params['filter_class'])) { $class = trim($params['filter_class']); } $element->setAttribute('class', 'filter form-control ' . $class); // $value = $session->offsetGet($id); $element->setValue($value); $session->offsetSet($id, $value); $render .= sprintf('<td>%s</td>', $this->getRenderer()->formRow($element)); } else { $render .= '<td></td>'; } } return sprintf('<tfoot><tr>%s</tr><tfoot>', $render); }
private function getFormAntennaModel($id) { $objectManager = $this->getServiceLocator()->get('Doctrine\\ORM\\EntityManager'); $datas = array(); $form = null; if ($id) { $antenna = $objectManager->getRepository('Application\\Entity\\Antenna')->find($id); if ($antenna) { $datas['antenna'] = $antenna; $qb = $objectManager->createQueryBuilder(); $qb->select(array('p', 'c'))->from('Application\\Entity\\PredefinedEvent', 'p')->leftJoin('p.category', 'c')->andWhere('c INSTANCE OF Application\\Entity\\AntennaCategory'); $models = array(); foreach ($qb->getQuery()->getResult() as $model) { foreach ($model->getCustomFieldsValues() as $value) { if ($value->getCustomField()->getID() == $model->getCategory()->getAntennaField()->getId()) { if ($value->getValue() == $id) { $models[] = $model; } } } } $form = new \Zend\Form\Form("model"); $hidden = new \Zend\Form\Element\Hidden("id"); $hidden->setValue($id); $form->add($hidden); $select = new \Zend\Form\Element\Select("models"); $optionsModels = array(); foreach ($models as $model) { $optionsModels[$model->getId()] = $model->getName(); } $select->setValueOptions($optionsModels); if (count($optionsModels) == 0) { $select->setEmptyOption("Aucun modèle à associer"); } else { $select->setEmptyOption("Choisir le modèle à associer."); } $select->setLabel("Modèle : "); $form->add($select); $datas['form'] = $form; } } return $datas; }