/** * @group ZF-6070 */ public function testIndividualElementDecoratorsShouldOverrideGlobalElementDecorators() { $this->form->setOptions(array( 'elementDecorators' => array( 'ViewHelper', 'Label', ), 'elements' => array( 'foo' => array( 'type' => 'text', 'options' => array( 'decorators' => array( 'Errors', 'ViewHelper', ), ), ), ), )); $element = $this->form->getElement('foo'); $expected = array('Zend\Form\Decorator\Errors', 'Zend\Form\Decorator\ViewHelper'); $actual = array(); foreach ($element->getDecorators() as $decorator) { $actual[] = get_class($decorator); } $this->assertSame($expected, $actual); }
/** * @param array $config * @param array $params * @return ZF1 */ public function create(array $config, array $params) { $form = new ZF1(); $formComponent = new \Zend_Form(); $formComponent->setOptions($config['form']); foreach ($this->getActiveGroups($config['groups'], $params) as $groupConfig) { foreach ($groupConfig['elements'] as $elementConfig) { $element = $this->getDic()->get('form.element.zf1factory')->create($elementConfig, $params); $formComponent->addElement($element); } } $form->setFormComponent($formComponent); return $form; }
public function setOptions(array $options) { if (isset($options['model'])) { $this->_model = $options['model']; } //adapter must be set after the model if (isset($options['adapter'])) { $this->setAdapter($options['adapter']); } if (isset($options['ignoreFields'])) { $this->setIgnoreFields($options['ignoreFields']); } if (isset($options['columnTypes'])) { $this->setColumnTypes($options['columnTypes']); } if (isset($options['fieldLabels'])) { $this->setFieldLabels($options['fieldLabels']); } if (isset($options['fieldTypes'])) { $this->setFieldTypes($options['fieldTypes']); } if (isset($options['generateManyFields'])) { $this->setGenerateManyFields($options['generateManyFields']); } parent::setOptions($options); }
/** * Set form state from options array * * @return Zend_Form */ public function setOptions() { $options = $this->_getOptions()->toArray(); if (isset($options['importDisplayGroups'])) { $this->_extraDisplayGroups = $options['importDisplayGroups']; unset($options['importDisplayGroups']); } if (!isset($options['id'])) { $id = $this->_module . '-' . $this->_formConfigFile . '-form'; $id = Zend_Filter::filterStatic($id, 'DashToCamelCase') . mt_rand(); $id = lcfirst($id); $options['id'] = $id; } parent::setOptions($options); return $this; }