public function testCanSetCustomOptionFromConstructor() { $fieldset = new Fieldset('foo', array('custom' => 'option')); $options = $fieldset->getOptions(); $this->assertArrayHasKey('custom', $options); $this->assertEquals('option', $options['custom']); }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { if ($fieldset->getName()) { return parent::renderFieldset($view, $fieldset); } // Reimplement form renderer to align submit button with elements from Preferences fieldset. $output = "<div class='table'>\n"; foreach ($this->get('Preferences') as $element) { if ($element instanceof \Zend\Form\Fieldset) { $output .= $view->htmlElement('span', $view->translate($element->getLabel()), array('class' => 'label'), true) . "\n"; $output .= $view->htmlElement('fieldset', "<legend></legend>\n" . $this->renderFieldset($view, $element)); } else { $output .= $view->formRow($element, 'prepend', false); if ($element->getMessages()) { $output .= "\n<div class='row'>\n<span class='cell'></span>\n"; $output .= $view->formElementErrors($element, array('class' => 'errors')); $output .= "\n</div>"; } } $output .= "\n"; } $output .= "<div class='row'>\n"; $output .= "<span class='cell'></span>\n"; $output .= $view->formRow($this->get('Submit')); $output .= "\n</div>\n</div>\n"; return $output; }
/** * @outputBuffering disabled */ public function testCanRenderFieldsets() { $this->expectOutputRegex('/<form(.*)<fieldset(.*)<\\/fieldset>(.*)<fieldset(.*)<\\/fieldset>(.*)<\\/form>/'); $form = new NetsensiaForm(); $form->addHidden('test1', 'testvalue'); $hidden = new Element\Hidden('asdasd'); $hidden->setValue('123'); $form->add($hidden); $element1 = new Text('testelement1'); $element1->setLabel('Test Element'); $element1->setAttribute('icon', 'pencil'); $element2 = new Text('testelement2'); $element2->setLabel('Test Element 2'); $element2->setAttribute('icon', 'pencil'); $fieldset1 = new Fieldset('testfieldset1'); $fieldset1->add($element1); $fieldset2 = new Fieldset('testfieldset2'); $fieldset2->add($element2); $form->add($fieldset1); $form->add($fieldset2); $helpers = new HelperPluginManager(); $helpers->setService('formElement', new FormElement()); $view = new PhpRenderer(); $view->setHelperPluginManager($helpers); $viewHelper = new BootstrapForm(); $viewHelper->setView($view); $viewHelper($form, 'testform', '/'); }
/** * Load upload prevalue editor * * @return string */ public function load() { $parameters = $this->getConfig(); $elements = array(); $optionsValues = !empty($parameters['options']) ? $parameters['options'] : array(); $fieldset = new Fieldset('Available options'); $element = new Element\MultiCheckbox('options'); $element->setAttribute('selected', $optionsValues); $element->setAttribute('class', 'input-checkbox'); $element->setValueOptions(array(array('value' => 'maxNumberOfFiles', 'label' => 'Is multiple', 'selected' => empty($optionsValues['maxNumberOfFiles']) ? false : true))); $fieldset->add($element); $elements[] = $fieldset; $element = new Element\MultiCheckbox('mime_list'); $mimeList = array('image/gif', 'image/jpeg', 'image/png', 'image/tiff', 'image/svg+xml', 'text/css', 'text/csv', 'text/html', 'text/javascript', 'text/plain', 'text/xml', 'video/mpeg', 'video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/x-msvideo', 'video/x-flv', 'audio/mpeg', 'audio/x-ms-wma', 'audio/vnd.rn-realaudio', 'audio/x-wav'); $options = array(); foreach ($mimeList as $mime) { $options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($parameters['mime_list']) ? array() : $parameters['mime_list']) ? false : true); } $element->setValueOptions($options); $element->setAttribute('class', 'input-checkbox'); $fieldset = new Fieldset('Mime list'); $fieldset->add($element); $elements[] = $fieldset; return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => $elements)); }
public function addButtons() { $fieldSet = new Fieldset('buttons'); $fieldSet->setAttributes(array('class' => 'dots-form-buttons')); $fieldSet->add(array('name' => 'cancel', 'options' => array('label' => 'Cancel'), 'attributes' => array('type' => 'button', 'class' => 'btn', 'data-action' => 'link_cancel'))); $fieldSet->add(array('name' => 'save', 'options' => array('label' => 'Save'), 'attributes' => array('type' => 'button', 'class' => 'btn btn-primary', 'data-action' => 'link_save'))); $this->add($fieldSet); }
/** * Produce a form element. * * @param Affiliation $affiliation * @param ProjectService $projectService */ public function __construct(Affiliation $affiliation, ProjectService $projectService) { parent::__construct($affiliation->getId()); foreach ($projectService->parseEditYearRange() as $year) { $fieldSet = new Fieldset($year); $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'cost', 'attributes' => ['class' => 'form-control cost-input year-' . $year, 'label' => 'cost', 'placeholder' => _("txt-cost")]]); $this->add($fieldSet); } }
public function setUp() { $fs = new Fieldset('test', ['type' => "text"]); $fs->setAttribute('class', 'myclass1 myclass2'); $fs->setName('myField'); $target = new Form(); $target->add($fs); $this->target = $target; }
/** * Prepare elements for configuration * * @return void */ public function prepareConfig() { $options = $this->getModel()->getConfig(); $fieldset = new Fieldset('config'); $language = new Element\Select('language'); $language->setLabel('Language')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValueOptions($this->getModel()->getLanguages())->setValue($options['language']); $fieldset->add($language); $ga = new Element\Text('data_ga_property_id'); $ga->setLabel('Google Analytics property ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['data_ga_property_id']); $fieldset->add($ga); $showOnDashboard = new Element\Checkbox('show_stats'); $showOnDashboard->setLabel('Show stats on dashboard')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'show_stats')->setAttribute('class', 'input-checkbox')->setValue($options['show_stats']); $fieldset->add($showOnDashboard); $profileId = new Element\Text('profile_id'); $profileId->setLabel('AddThis Profile ID')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['profile_id']); $fieldset->add($profileId); $username = new Element\Text('username'); $username->setLabel('AddThis Username')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['username']); $fieldset->add($username); $password = new Element\Password('password'); $password->setLabel('AddThis Password')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['password']); $fieldset->add($password); $dataTrackClickback = new Element\Checkbox('data_track_clickback'); $dataTrackClickback->setLabel('Track clickback')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_clickback')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_clickback']); $fieldset->add($dataTrackClickback); $dataTrackAddressbar = new Element\Checkbox('data_track_addressbar'); $dataTrackAddressbar->setLabel('Track adressbar')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('id', 'data_track_addressbar')->setAttribute('class', 'input-checkbox')->setValue($options['data_track_addressbar']); $fieldset->add($dataTrackAddressbar); $jsonConfig = new Element\Textarea('config_json'); $jsonConfig->setLabel('Json config')->setLabelAttributes(array('class' => 'col-lg-2 control-label'))->setAttribute('class', 'form-control col-lg-10')->setValue($options['config_json']); $fieldset->add($jsonConfig); $this->add($fieldset); $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'language' => array('name' => 'language', 'required' => true), 'data_ga_property_id' => array('name' => 'data_ga_property_id', 'required' => false), 'profile_id' => array('name' => 'profile_id', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) { if (empty($context['username']) or empty($context['password'])) { return false; } return true; })))), 'show_stats' => array('name' => 'show_stats', 'required' => false), 'password' => array('name' => 'password', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) { if (empty($context['username']) or empty($context['profile_id'])) { return false; } return true; })))), 'username' => array('name' => 'username', 'required' => false, 'validators' => array(array('name' => 'Callback', 'options' => array('messages' => array(\Zend\Validator\Callback::INVALID_VALUE => 'Can not connect to addthis api'), 'callback' => function ($value, $context = array()) { $client = new Client('https://api.addthis.com/analytics/1.0/pub/shares.json', array('sslverifypeer' => false)); $client->setParameterGet(array('username' => $context['username'], 'password' => $context['password'], 'pubid' => $context['profile_id'])); try { $response = $client->send(); if ($response->isSuccess() == 200) { return true; } } catch (\Exception $e) { //don't care } return false; })))), 'data_track_clickback' => array('name' => 'data_track_clickback', 'required' => false), 'data_track_addressbar' => array('name' => 'data_track_addressbar', 'required' => false), 'json_config' => array('name' => 'json_config', 'required' => false)), 'config'); }
public function addSiteEnableCheckbox($event) { $siteSettings = $this->getServiceLocator()->get('Omeka\\SiteSettings'); $form = $event->getParam('form'); $fieldset = new Fieldset('sharing'); $fieldset->setLabel('Sharing'); $enabledMethods = $siteSettings->get('sharing_methods', array()); $fieldset->add(['name' => 'sharing_methods', 'type' => 'multiCheckbox', 'options' => ['label' => 'Enable Sharing module for these methods', 'value_options' => ['fb' => ['label' => 'Facebook', 'value' => 'fb', 'selected' => in_array('fb', $enabledMethods)], 'twitter' => ['label' => 'Twitter', 'value' => 'twitter', 'selected' => in_array('twitter', $enabledMethods)], 'tumblr' => ['label' => 'Tumblr', 'value' => 'tumblr', 'selected' => in_array('tumblr', $enabledMethods)], 'pinterest' => ['label' => 'Pinterest', 'value' => 'pinterest', 'selected' => in_array('pinterest', $enabledMethods)], 'email' => ['label' => 'Email', 'value' => 'email', 'selected' => in_array('email', $enabledMethods)], 'embed' => ['label' => 'Embed codes', 'value' => 'embed', 'selected' => in_array('embed', $enabledMethods)]]], 'attributes' => ['required' => false]]); $form->add($fieldset); }
/** * @param GeneralService $mailingService */ public function __construct(GeneralService $mailingService) { parent::__construct(); $this->setAttribute('method', 'get'); $this->setAttribute('action', ''); $filterFieldset = new Fieldset('filter'); $filterFieldset->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'search', 'attributes' => ['class' => 'form-control', 'placeholder' => _('txt-search')]]); $this->add($filterFieldset); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['id' => 'submit', 'class' => 'btn btn-primary', 'value' => _('txt-filter')]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'clear', 'attributes' => ['id' => 'cancel', 'class' => 'btn btn-warning', 'value' => _('txt-cancel')]]); }
public function createService(ServiceLocatorInterface $serviceLocator) { $form = new Form(); $form->setName('login-form'); $form->add(array('type' => 'hidden', 'name' => 'ref')); $fieldset = new Fieldset(); $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name', 'description' => 'Provide your login key (e.g. email adress)'))); $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password'))); $form->add($fieldset); $form->add($this->forms->get('DefaultButtonsFieldset')); }
/** * @param Fieldset $fieldset */ protected function handleCollections(Fieldset $fieldset) { foreach ($fieldset->getFieldsets() as $childFieldset) { // Configure collection: if ($childFieldset instanceof Collection) { $this->configureInputFilter($childFieldset); } // Search deeper: $this->handleCollections($childFieldset); } }
public function addLeadFieldset($name = 'leads', $leadData = array()) { $leadAttributeValuesFieldset = new Fieldset($name, ['use_as_base_fieldset' => false]); if ($leadData) { foreach ($leadData as $i => $lead) { foreach ($lead as $field => $value) { $leadAttributeValuesFieldset->add(array('name' => "{$i}[{$field}]", 'attributes' => array('value' => $value, 'type' => 'hidden'))); } } } $this->add($leadAttributeValuesFieldset); return $leadAttributeValuesFieldset; }
/** {@inheritdoc} */ public function renderFieldset(\Zend\View\Renderer\PhpRenderer $view, \Zend\Form\Fieldset $fieldset) { $output = ''; if ($fieldset->getName() == 'Deploy') { foreach ($fieldset as $element) { // Default renderer would prepend $output .= $view->formRow($element, 'append') . "\n"; } } else { $output .= parent::renderFieldset($view, $fieldset); } return $output; }
public function addSubmissionsFieldset($name = 'submissions', $submissions = array()) { $submissionsFieldset = new Fieldset($name, ['use_as_base_fieldset' => false]); if ($submissions) { foreach ($submissions as $i => $submission) { foreach ($submission as $field => $value) { $submissionsFieldset->add(array('name' => "{$i}[{$field}]", 'attributes' => array('value' => $value, 'type' => 'hidden'))); } } } $this->add($submissionsFieldset); return $submissionsFieldset; }
public function init() { $this->setName('login-form'); $this->setAttribute('data-handle-by', 'native'); $fieldset = new Fieldset('credentials'); //$fieldset->setLabel('Enter your credentials'); $fieldset->setOptions(array('renderFieldset' => true)); $fieldset->add(array('name' => 'login', 'options' => array('label' => 'Login name'))); $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('label' => 'Password'))); $this->add($fieldset); $buttons = new \Core\Form\ButtonsFieldset('buttons'); $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary'))); $this->add($buttons); }
public function __construct($name = 'login-form', $options = array()) { parent::__construct($name, $options); $this->setAttribute('data-handle-by', 'native'); $this->setAttribute('class', 'form-inline'); $fieldset = new Fieldset('credentials'); $fieldset->setOptions(array('renderFieldset' => true)); $fieldset->add(array('name' => 'login', 'options' => array('id' => 'login', 'label' => 'Login name'))); $fieldset->add(array('type' => 'password', 'name' => 'credential', 'options' => array('id' => 'credential', 'label' => 'Password'))); $this->add($fieldset); $buttons = new \Core\Form\ButtonsFieldset('buttons'); $buttons->add(array('type' => 'submit', 'name' => 'button', 'attributes' => array('id' => 'submit', 'type' => 'submit', 'value' => 'login', 'class' => 'btn btn-primary'))); $this->add($buttons); }
/** * Class constructor */ public function __construct() { parent::__construct(); $this->setAttribute('method', 'get'); $this->setAttribute('class', 'form-horizontal'); for ($i = 0; $i <= 2; $i++) { $filter = new Fieldset('selection' . $i); $filter->add(['type' => 'Zend\\Form\\Element\\Select', 'name' => 'in', 'options' => ['value_options' => $this->inOptions], 'attributes' => ['label' => 'search']]); $filter->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'selection', 'attributes' => ['label' => 'search', 'class' => 'form-control', 'id' => "search", 'placeholder' => _("txt-site-search")]]); $this->add($filter); } $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-danger", 'value' => _("txt-cancel")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-submit")]]); }
/** * Class constructor. * * @param ProjectService $projectService * @param WorkpackageService $workpackageService */ public function __construct(ProjectService $projectService, WorkpackageService $workpackageService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $fieldSet = new Fieldset('effortPerAffiliationAndYear'); foreach ($workpackageService->findWorkpackageByProjectAndWhich($projectService->getProject()) as $workpackage) { $workpackageFieldSet = new EffortPerWorkpackageAndAffiliationFieldset($workpackage, $projectService); $fieldSet->add($workpackageFieldSet); } $fieldSet->setUseAsBaseFieldset(true); $this->add($fieldSet); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-planned-versus-spent")]]); }
/** * Class constructor. */ public function __construct(ProjectService $projectService) { parent::__construct(); $this->setAttribute('method', 'post'); $this->setAttribute('class', 'form-horizontal'); $valueChainFieldSet = new Fieldset('affiliation'); foreach ($projectService->getAffiliation() as $affiliationService) { $fieldSet = new Fieldset($affiliationService->getAffiliation()->getId()); $fieldSet->add(['type' => 'Zend\\Form\\Element\\Text', 'name' => 'valueChain', 'options' => ['label' => sprintf(_("%s from %s"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())], 'attributes' => ['class' => 'form-control', 'placeholder' => sprintf(_("Posistion of %s on the value chain"), $affiliationService->getAffiliation()->getOrganisation(), $affiliationService->getAffiliation()->getOrganisation()->getCountry())]]); $valueChainFieldSet->add($fieldSet); } $this->add($valueChainFieldSet); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'submit', 'attributes' => ['class' => "btn btn-primary", 'value' => _("txt-update-value-chain")]]); $this->add(['type' => 'Zend\\Form\\Element\\Submit', 'name' => 'cancel', 'attributes' => ['class' => "btn btn-warning", 'value' => _("txt-cancel")]]); }
/** * Build a fieldSet view Model * @param Fieldset $fieldSet * @param ViewModel $parentViewModel */ protected function buildFieldSetViewModel(Fieldset $fieldSet, ViewModel &$parentViewModel) { $object = $fieldSet->getObject(); $fieldSetViewModel = new ViewModel(); if (is_object($object)) { $fieldSetViewModel->setVariables(['object' => $object, 'title' => $this->getFieldSetTitle($object)]); } $fieldSetViewModel->setTemplate('form/fieldset'); if ($fieldSet instanceof Element\Collection) { $fieldSetViewModel->setTemplate('form/element/collection'); } $fieldSetViewModel->setVariable('fieldSet', $fieldSet); $this->buildFormViewModel($fieldSet, $fieldSetViewModel); $parentViewModel->addChild($fieldSetViewModel, 'elements', true); }
public function __construct() { parent::__construct('category'); $this->setHydrator(new ArraySerializableHydrator())->setObject(new Category()); $this->setLabel('Category'); $this->add(array('name' => 'name', 'options' => array('label' => 'Name of the category'), 'attributes' => array())); }
/** * @param EntityManager $entityManager */ public function __construct(EntityManager $entityManager) { parent::__construct('doa'); $doa = new Entity\Doa(); $doctrineHydrator = new DoctrineHydrator($entityManager, 'Affiliation\\Entity\\Doa'); $this->setHydrator($doctrineHydrator)->setObject($doa); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($doa)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect) { $element->setOptions(['object_manager' => $entityManager]); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } $this->add(['type' => '\\Zend\\Form\\Element\\Select', 'name' => 'contact', 'options' => ["label" => "txt-signer"]]); $this->add(['type' => '\\Zend\\Form\\Element\\File', 'name' => 'file', 'options' => ["label" => "txt-source-file", "help-block" => _("txt-attachment-requirements")]]); }
public function __construct($academicperiodid, \Doctrine\ORM\EntityManager $em = null, $classid = null, $classmodule = null) { $this->em = $em; $this->classid = $classid; $this->academicperiodid = $academicperiodid; parent::__construct('Classmodule'); $this->setHydrator(new ClassMethodsHydrator(false))->setObject(new Classmodule()); if ($classmodule == NULL) { $this->add(array('name' => 'fkModuleid', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('class' => 'form-control', 'id' => 'fkModuleid'), 'options' => array('label' => 'Module:*', 'value_options' => $this->getAvailableModules(), 'empty_option' => "--Select module--"))); } else { $this->add(array('name' => 'fkModuleid', 'type' => 'Hidden')); } /* * Configure examweight field to form */ $this->add(array('name' => 'exweight', 'type' => 'Zend\\Form\\Element\\Number', 'attributes' => array('class' => 'form-control', 'id' => 'exweight'), 'options' => array('label' => 'Exam weight*:'))); /* * Configure id field to form */ $this->add(array('name' => 'pkClassmoduleid', 'type' => 'hidden')); /* * Configure academic period */ $this->add(array('name' => 'fkAcademicperiod', 'type' => 'Zend\\Form\\Element\\Select', 'attributes' => array('class' => 'form-control', 'id' => 'fkAcademicperiod'), 'options' => array('label' => 'Semester:*', 'value_options' => $this->getSemesters(), 'empty_option' => "--Select semester--"))); /* * Configure examweight field to form */ $this->add(array('name' => 'cwkweight', 'type' => 'Zend\\Form\\Element\\Number', 'attributes' => array('class' => 'form-control', 'id' => 'cwkweight'), 'options' => array('label' => 'Course work weight:*'))); $this->add(array('name' => 'fkClassid', 'type' => 'hidden')); $this->add(array('type' => 'Zend\\Form\\Element\\Radio', 'name' => 'isCore', 'options' => array('label' => 'Is core:*', 'value_options' => array("1" => "Yes", "0" => "No")))); $this->add(array('type' => 'Zend\\Form\\Element\\Radio', 'name' => 'isProject', 'options' => array('label' => 'Is project:*', 'value_options' => array("1" => "Yes", "0" => "No")))); }
/** * @param EntityManager $entityManager * @param Entity\EntityAbstract $object */ public function __construct(EntityManager $entityManager, Entity\EntityAbstract $object) { parent::__construct($object->get('underscore_entity_name')); $doctrineHydrator = new DoctrineHydrator($entityManager); $this->setHydrator($doctrineHydrator)->setObject($object); $builder = new AnnotationBuilder(); /** * Go over the different form elements and add them to the form */ foreach ($builder->createForm($object)->getElements() as $element) { /** * Go over each element to add the objectManager to the EntitySelect */ if ($element instanceof EntitySelect || $element instanceof EntityMultiCheckbox) { $element->setOptions(array_merge_recursive($element->getOptions(), ['object_manager' => $entityManager])); } if ($element instanceof Radio) { $attributes = $element->getAttributes(); $valueOptionsArray = 'get' . ucfirst($attributes['array']); $element->setOptions(array_merge_recursive($element->getOptions(), ['value_options' => $object->{$valueOptionsArray}()])); } //Add only when a type is provided if (array_key_exists('type', $element->getAttributes())) { $this->add($element); } } }
public function __construct() { parent::__construct('ProductVariantFieldset'); $this->setHydrator(new ClassMethodsHydrator(false))->setObject(new Category()); $this->setLabel('Product Variant'); $this->add(array('type' => 'Zend\\Form\\Element\\Select', 'name' => 'variant', 'attributes' => array('class' => 'form-control form-element'), 'options' => array('label' => 'Product Variant', 'label_attributes' => array('class' => 'media-object')))); }
/** * @param object $object * @return $this|Fieldset|\Zend\Form\FieldsetInterface */ public function setObject($object) { parent::setObject($object); //$this->get('contact')->setObject($object->contact); //$this->populateValues($this->extract()); return $this; }
public function __construct(array $options = []) { parent::__construct('foo-fieldset', $options); $this->add(['type' => Text::class, 'name' => 'fooText', 'options' => ['label' => 'Some Text Element']]); $this->add(['type' => Select::class, 'name' => 'fooSelect', 'options' => ['label' => 'Some Select Element', 'value_options' => ['foo' => 'Foo', 'bar' => 'Bar'], 'empty_option' => '--- Foo or Bar? ---']]); $this->add(['type' => Collection::class, 'name' => 'barCollection', 'options' => ['label' => 'A Bar', 'count' => 2, 'should_create_template' => true, 'allow_add' => true, 'template_placeholder' => '__bar__', 'target_element' => ['type' => BarFieldset::class]]]); }
public function __construct() { // we want to ignore the name passed parent::__construct('navigation_page_params'); $this->add(array('name' => 'param_name', 'attributes' => array('type' => 'text', 'placeholder' => 'Name', 'id' => 'param_name'), 'options' => array('label' => 'Name'))); $this->add(array('name' => 'param_value', 'attributes' => array('type' => 'text', 'placeholder' => 'Value', 'id' => 'param_value'), 'options' => array('label' => 'Value'))); }
public function __construct($sm) { parent::__construct('resetPassword'); $this->sm = $sm; $altesPasswort = new Password('oldPass'); $altesPasswort->setLabel('LABEL_CHANGE_PASSWORD_OLD_PASS'); $altesPasswort->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $altesPasswort->setAttribute('class', 'form-control'); $altesPasswort->setAttribute('id', 'oldPass'); $this->add($altesPasswort); $neuesPasswort = new Password('newPass'); $neuesPasswort->setLabel('LABEL_CHANGE_PASSWORD_NEW_PASS'); $neuesPasswort->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $neuesPasswort->setAttribute('class', 'form-control'); $neuesPasswort->setAttribute('id', 'newPass'); $this->add($neuesPasswort); $neuesPasswortConfirm = new Password('newPassConfirm'); $neuesPasswortConfirm->setLabel('LABEL_CHANGE_PASSWORD_NEW_CONFIRM'); $neuesPasswortConfirm->setLabelAttributes(array('class' => 'col-sm-2 control-label')); $neuesPasswortConfirm->setAttribute('class', 'form-control'); $neuesPasswortConfirm->setAttribute('id', 'newPassConfirm'); $this->add($neuesPasswortConfirm); $submit = new Submit('resetPasswordSubmit'); $submit->setValue('LABEL_CHANGE_PASSWORD_SUBMIT'); $submit->setAttribute('class', 'btn btn-default'); $this->add($submit); return $this; }