Beispiel #1
0
 /**
  * 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));
 }
Beispiel #2
0
 /**
  * Load checkbox list editor
  *
  * @return Element\MultiCheckbox
  */
 public function load()
 {
     $parameters = $this->getConfig();
     $element = new Element\MultiCheckbox($this->getName());
     if (!empty($parameters)) {
         $element->setValueOptions($parameters);
     }
     $element->setLabel($this->getProperty()->getName())->setAttribute('id', $this->getName())->setAttribute('required', $this->getProperty()->isRequired())->setAttribute('class', 'input-checkbox')->setValue($this->getValue());
     return $element;
 }
Beispiel #3
0
 protected function addMultiCheckbox($name, $label, array $data)
 {
     $multiCheckbox = new Element\MultiCheckbox($name);
     $multiCheckbox->setLabel($label);
     $multiCheckbox->setLabelAttributes(array('class' => "col-sm-{$this->labelWidth}"));
     $multiCheckbox->setValueOptions($data);
     $multiCheckbox->setOption('column-size', "sm-{$this->controlWidth}");
     $multiCheckbox->setOption('inline', true);
     $this->add($multiCheckbox);
     return $this;
 }
 function __construct(array $associations = [])
 {
     parent::__construct('taxonomyTerm');
     $this->setAttribute('method', 'post');
     $filter = new InputFilter();
     $this->setInputFilter($filter);
     $this->add((new Text('destination'))->setAttribute('id', 'destination')->setAttribute('placeholder', 'ID (12345)')->setLabel('Move to:'));
     $multiCheckbox = new MultiCheckbox('associations');
     $multiCheckbox->setLabel('Elements')->setAttribute('id', 'associations');
     $multiCheckbox->setValueOptions($associations);
     $this->add($multiCheckbox);
     $this->add((new Submit('submit'))->setValue('Save')->setAttribute('class', 'btn btn-success pull-right'));
     $filter->add(['name' => 'destination', 'required' => true, 'allow_empty' => false, 'filters' => [['name' => 'Int']], 'validators' => [['name' => 'Digits']]]);
 }
Beispiel #5
0
 public function __construct()
 {
     parent::__construct('AddRecipeForm');
     $noOfPeopleElement = new Text('NoOfPeople');
     $noOfPeopleElement->setLabel('Anzahl Personen');
     $this->add($noOfPeopleElement);
     // Add Text for kcal.
     //TODO: Rescrict input to integers
     $kcalElement = new Text('Kcal');
     $kcalElement->setLabel('Anzahl Kalorien');
     $this->add($kcalElement);
     // Add Checkbox for publicFlag
     $publicFlagElement = new Checkbox('PublicFlag');
     $publicFlagElement->setLabel('Möchten Sie das Rezept öffentlich speichern?');
     $this->add($publicFlagElement);
     $preparationTimeElement = new Text('PreparationTime');
     $preparationTimeElement->setLabel('Vorbereitungszeit');
     $this->add($preparationTimeElement);
     $cookingTimeElement = new Text('CookingTime');
     $cookingTimeElement->setLabel('Koch- / Backzeit');
     $this->add($cookingTimeElement);
     $restingTimeElement = new Text('RestingTime');
     $restingTimeElement->setLabel('Ruhezeit');
     $this->add($restingTimeElement);
     $types = $this->selectAllFrom('Types', 'Name');
     $typeElement = new MultiCheckbox('TypeId');
     $typeElement->setLabel('Rezept Typ');
     //$possibleValues = array('Sommermenu','Herbstmenu','Wintermenu','Frühlingsmenu');
     $typeElement->setValueOptions($types);
     $this->add($typeElement);
     $levels = $this->selectAllFrom('Levels', 'Shortname');
     $levelElement = new Select('Level');
     $levelElement->setLabel('Schwierigkeit');
     $levelElement->setValueOptions($levels);
     /*array('einfach','schwierig'));*/
     $levelElement->setValue($levels[0]);
     $this->add($levelElement);
     // Add steps
     $this->addSteps($this->getMaxNumberOfSteps());
     // Add select for chosing how many steps should be displayed
     $stepNumbers = range(1, $this->maxNoOfSteps);
     $addStepSelect = new Select('StepNumber');
     $addStepSelect->setLabel('Anzahl Schritte wählen');
     $addStepSelect->setValueOptions($stepNumbers);
     $addStepSelect->setAttribute('id', 'NoOfStepSelect');
     $addStepSelect->setAttribute('onchange', 'show(++this.value)');
     $this->add($addStepSelect);
 }
Beispiel #6
0
 /**
  * Load upload prevalue editor
  *
  * @return Element\Checkbox[]
  */
 public function load()
 {
     $config = $this->getConfig();
     $isMultiple = new Element\Checkbox('is_multiple');
     $isMultiple->setAttributes(array('value' => isset($config['is_multiple']) ? $config['is_multiple'] : '', 'class' => 'input-checkbox', 'id' => 'is_multiple'));
     $isMultiple->setOptions(array('label' => 'Is Multiple', 'label_attributes' => array('class' => 'required control-label col-lg-2')));
     $mimeList = new Element\MultiCheckbox('mime_list');
     $array = 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 ($array as $mime) {
         $options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($config['mime_list']) ? array() : $config['mime_list']) ? false : true);
     }
     $mimeList->setAttribute('class', 'input-checkbox');
     $mimeList->setValueOptions($options);
     return array($isMultiple, $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('mimeList' => $mimeList)));
 }
 public function __construct()
 {
     $dbAdapter = Zend\Db\TableGateway\Feature\GlobalAdapterFeature::getStaticAdapter();
     $this->setDbAdapter($dbAdapter);
     parent::__construct('recipefieldset');
     $this->add(array('name' => 'noOfPeople', 'type' => 'Text', 'options' => array('label' => 'Anzahl Personen')));
     // Add Text for kcal.
     //TODO: Rescrict input to integers
     $kcalElement = new Text('kcal');
     $kcalElement->setLabel('Anzahl Kalorien');
     $this->add($kcalElement);
     // Add Checkbox for publicFlag
     $publicFlagElement = new Checkbox('publicFlag');
     $publicFlagElement->setLabel('Möchten Sie das Rezept öffentlich speichern?');
     $this->add($publicFlagElement);
     $typeElement = new MultiCheckbox('typeId');
     $typeElement->setLabel('Rezept Typ');
     $possibleValues = array('Sommermenu', 'Herbstmenu', 'Wintermenu', 'Frühlingsmenu');
     $typeElement->setValueOptions($possibleValues);
     $this->add($typeElement);
     $selectString = 'SELECT * FROM Levels';
     //$select->getSqlString();
     $result = $dbAdapter->query($selectString, Adapter::QUERY_MODE_EXECUTE);
     $levels = array();
     foreach ($result as $row) {
         $levels[] = $row['Shortname'];
     }
     $levelElement = new Select('level');
     $levelElement->setLabel('Schwierigkeit');
     $levelElement->setValueOptions($levels);
     /*array('einfach','schwierig'));*/
     $this->add($levelElement);
     // Add steps
     $this->addSteps(4);
     $stepNumbers = range(1, $this->maxNoOfSteps);
     $addStepSelect = new Select('stepNumber');
     $addStepSelect->setLabel('Anzahl Schritte wählen');
     $addStepSelect->setValueOptions($stepNumbers);
     $addStepSelect->setAttribute('id', 'noOfStepSelect');
     $addStepSelect->setAttribute('onchange', 'show()');
     $this->add($addStepSelect);
 }
Beispiel #8
0
 public function __construct(array $roles)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $this->setAttribute('class', 'panel-body');
     $name = new Text('name');
     $name->setLabel('name');
     $name->setAttribute('class', 'form-control');
     $this->add($name);
     $parent = new MultiCheckbox('parent');
     $parent->setLabel('parent');
     $parent->setUseHiddenElement(true);
     $parent->setValueOptions($roles);
     $this->add($parent);
     $this->getInputFilter()->get($parent->getName())->setAllowEmpty(true);
     $submit = new Submit('save');
     $submit->setValue('save');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
Beispiel #9
0
 /**
  * Load Image cropper prevalue editor
  *
  * @return string
  */
 public function load()
 {
     $config = $this->getConfig();
     $resizeOption = new Element\Select('resize_option');
     $resizeOption->setValue(empty($config['resize_option']) ? 'auto' : $config['resize_option'])->setAttribute('class', 'form-control')->setAttribute('id', 'resize-option')->setLabel('Resize option')->setLabelAttributes(array('class' => 'col-lg-2'))->setValueOptions(array('auto' => 'auto', 'crop' => 'crop'));
     $backgroundOption = new Element\Text('background');
     $backgroundOption->setValue(empty($config['background']) ? '' : $config['background'])->setAttribute('class', 'form-control')->setAttribute('id', 'background')->setLabel('Background color')->setLabelAttributes(array('class' => 'col-lg-2'));
     $mimeList = new Element\MultiCheckbox('mime_list');
     $mimeList->setAttribute('class', 'input-checkbox')->setLabel('Mime list')->setLabelAttributes(array('class' => 'col-lg-2'));
     $array = array('image/gif', 'image/jpeg', 'image/png');
     $options = array();
     foreach ($array as $mime) {
         $options[] = array('value' => $mime, 'label' => $mime, 'selected' => !in_array($mime, empty($config['mime_list']) ? array() : $config['mime_list']) ? false : true);
     }
     $mimeList->setValueOptions($options);
     $sizeElements = array();
     $idx = 0;
     if (!empty($config['size'])) {
         foreach ($config['size'] as $idx => $size) {
             $elementSizeName = new Element\Text('size[' . $idx . '][name]');
             $elementSizeName->setValue($size['name'])->setAttribute('class', 'form-control')->setAttribute('id', 'name' . $idx)->setLabel('Name');
             $elementWidth = new Element\Text('size[' . $idx . '][width]');
             $elementWidth->setValue($size['width'])->setAttribute('class', 'form-control')->setAttribute('id', 'width' . $idx)->setLabel('Width');
             $elementHeight = new Element\Text('size[' . $idx . '][height]');
             $elementHeight->setValue($size['height'])->setAttribute('class', 'form-control')->setAttribute('id', 'height' . $idx)->setLabel('Height');
             $sizeElements[] = array($elementSizeName, $elementWidth, $elementHeight);
         }
         $idx++;
     }
     $elementSizeName = new Element\Text('size[#{idx}][name]');
     $elementSizeName->setAttribute('id', 'name#{idx}')->setAttribute('class', 'form-control')->setLabel('Name');
     $elementWidth = new Element\Text('size[#{idx}][width]');
     $elementWidth->setLabel('Width')->setAttribute('class', 'form-control')->setAttribute('id', 'width#{idx}');
     $elementHeight = new Element\Text('size[#{idx}][height]');
     $elementHeight->setLabel('Height')->setAttribute('class', 'form-control')->setAttribute('id', 'height#{idx}');
     $template = array($elementSizeName, $elementWidth, $elementHeight);
     return $this->addPath(__DIR__)->render('upload-prevalue.phtml', array('elements' => array('resize-option' => $resizeOption, 'background' => $backgroundOption, 'mime' => $mimeList, 'size' => $sizeElements, 'size-template' => $template)));
 }
 public function testGetSelectedAttributeForGroupReturnTrue()
 {
     $element = new MultiCheckboxElement('foo');
     $element->setAttribute('selected', 'true');
     $element->setValueOptions(array(array('label' => 'label1', 'value' => 'value1')));
     $markup = $this->helper->render($element);
     $this->assertRegexp('#value="value1" checked="checked"#', $markup);
 }
Beispiel #11
0
 /**
  * Builds fieldset with additional properties for the "monthly" repeat picker value.
  * It returns the built fieldset (used as a child of the "repeat" fieldset).
  * 
  * @return Fieldset
  */
 public function getRepeatMonthlyFieldset()
 {
     $repeatMonthlyFieldset = new Fieldset(self::MONTHLY);
     // Note that this field is rendered on the frontend without the view helper,
     // for more flexibility.
     $dayOfMonth = new Element\MultiCheckbox('dayOfMonth');
     $dayOfMonth->setLabel('Pick days');
     $dayOfMonth->setValueOptions(array_combine(range(1, 31), range(1, 31)));
     $repeatMonthlyFieldset->add($dayOfMonth);
     return $repeatMonthlyFieldset;
 }
Beispiel #12
0
 public function testInvokeSetLabelPositionToAppend()
 {
     $element = new MultiCheckboxElement('foo');
     $element->setValueOptions(array(array('label' => 'label1', 'value' => 'value1')));
     $this->helper->__invoke($element, 'append');
     $this->assertSame('append', $this->helper->getLabelPosition());
 }
Beispiel #13
0
 public function testCanTranslateContent()
 {
     $element = new MultiCheckboxElement('foo');
     $element->setValueOptions(array(array('label' => 'label1', 'value' => 'value1')));
     $markup = $this->helper->render($element);
     $mockTranslator = $this->getMock('Zend\\I18n\\Translator\\Translator');
     $mockTranslator->expects($this->exactly(1))->method('translate')->will($this->returnValue('translated content'));
     $this->helper->setTranslator($mockTranslator);
     $this->assertTrue($this->helper->hasTranslator());
     $markup = $this->helper->__invoke($element);
     $this->assertContains('>translated content<', $markup);
 }
Beispiel #14
0
 public function render($formPV, $id)
 {
     $form = new Form();
     $form->setAttribute('id', $id);
     $inputFilter = new \Zend\InputFilter\InputFilter();
     $factory = new InputFactory();
     foreach ($formPV as $element) {
         if (isset($element->line_text)) {
             $attributes = $element->line_text[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //$required    = ($attributes->data->required == 'true') ? true : false ;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Text($name);
             $element->setName($label);
             $element->setLabel($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
                 $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_email)) {
             $attributes = $element->line_email[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //$required    = ($attributes->data->required == 'true') ? true : false ;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Email($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
                 $options['messages'] = array(\Zend\Validator\StringLength::TOO_LONG => sprintf($this->getServiceManager()->get('translator')->translate('This field contains more than %s characters', 'playgroundgame'), $lengthMax));
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_checkbox)) {
             $attributes = $element->line_checkbox[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
             $element = new Element\MultiCheckbox($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($innerData as $value) {
                 $values[] = $value->label;
             }
             $element->setValueOptions($values);
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required)));
         }
         if (isset($element->line_paragraph)) {
             $attributes = $element->line_paragraph[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $placeholder = isset($attributes->data->placeholder) ? $attributes->data->placeholder : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $element = new Element\Textarea($name);
             $element->setName($label);
             $element->setLabel($label);
             $element->setAttributes(array('placeholder' => $placeholder, 'required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $options = array();
             $options['encoding'] = 'UTF-8';
             if ($lengthMin && $lengthMin > 0) {
                 $options['min'] = $lengthMin;
             }
             if ($lengthMax && $lengthMax > $lengthMin) {
                 $options['max'] = $lengthMax;
                 $element->setAttribute('maxlength', $lengthMax);
             }
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'filters' => array(array('name' => 'StripTags'), array('name' => 'StringTrim')), 'validators' => array(array('name' => 'StringLength', 'options' => $options)))));
         }
         if (isset($element->line_upload)) {
             $attributes = $element->line_upload[0];
             //print_r($attributes);
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             $required = $attributes->data->required == 'true' ? true : false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $filesizeMin = isset($attributes->data->filesize) ? $attributes->data->filesize->min : '';
             $filesizeMax = isset($attributes->data->filesize) ? $attributes->data->filesize->max : '';
             $element = new Element\File($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('required' => $required, 'class' => $class, 'id' => $id));
             $form->add($element);
             $inputFilter->add($factory->createInput(array('name' => $name, 'required' => $required, 'validators' => array(array('name' => '\\Zend\\Validator\\File\\Size', 'options' => array('max' => 10 * 1024 * 1024)), array('name' => '\\Zend\\Validator\\File\\Extension', 'options' => array('png,PNG,jpg,JPG,jpeg,JPEG,gif,GIF', 'messages' => array(\Zend\Validator\File\Extension::FALSE_EXTENSION => 'Veuillez télécharger une image')))))));
         }
         if (isset($element->line_radio)) {
             $attributes = $element->line_radio[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $innerData = isset($attributes->data->innerData) ? $attributes->data->innerData : array();
             $element = new Element\Radio($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($innerData as $value) {
                 $values[] = $value->label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
         if (isset($element->line_dropdown)) {
             $attributes = $element->line_dropdown[0];
             $name = isset($attributes->name) ? $attributes->name : '';
             $type = isset($attributes->type) ? $attributes->type : '';
             $position = isset($attributes->order) ? $attributes->order : '';
             $label = isset($attributes->data->label) ? $attributes->data->label : '';
             //                 $required    = ($attributes->data->required == 'yes') ? true : false;
             $required = false;
             $class = isset($attributes->data->class) ? $attributes->data->class : '';
             $id = isset($attributes->data->id) ? $attributes->data->id : '';
             $lengthMin = isset($attributes->data->length) ? $attributes->data->length->min : '';
             $lengthMax = isset($attributes->data->length) ? $attributes->data->length->max : '';
             $dropdownValues = isset($attributes->data->dropdownValues) ? $attributes->data->dropdownValues : array();
             $element = new Element\Select($name);
             $element->setLabel($label);
             $element->setName($label);
             $element->setAttributes(array('name' => $name, 'required' => $required, 'allowEmpty' => !$required, 'class' => $class, 'id' => $id));
             $values = array();
             foreach ($dropdownValues as $value) {
                 $values[] = $value->dropdown_label;
             }
             $element->setValueOptions($values);
             $form->add($element);
         }
     }
     $form->setInputFilter($inputFilter);
     return $form;
 }
Beispiel #15
0
 /**
  * Initialize infos sub form
  *
  * @return \Zend\Form\FieldSet
  */
 protected function getInfos()
 {
     $fieldsets = $this->getFieldSets();
     if (!empty($fieldsets['infos'])) {
         return $fieldsets['infos'];
     }
     $fieldsets = new FieldSet('infos');
     $this->getInputFilter()->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'db\\no_record_exists', 'options' => array('table' => 'document_type', 'field' => 'name', 'adapter' => $this->getAdapter())))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'icon_id' => array('name' => 'icon_id', 'required' => true, 'allow_empty' => false), 'dependency' => array('name' => 'dependency', 'required' => false, 'allow_empty' => true)), 'infos');
     $fieldsets->add(new Element\Text('name'));
     $fieldsets->add(new Element\Text('description'));
     $iconId = new Element\Select('icon_id');
     $collection = new Icon\Collection();
     $iconId->setValueOptions($collection->getIcons())->setAttribute('class', 'form-control');
     $fieldsets->add($iconId);
     $documentTypeCollection = new DocumentTypeCollection();
     $select = $documentTypeCollection->getSelect();
     if (!empty($select)) {
         $dependency = new Element\MultiCheckbox('infos[dependency]');
         $dependency->setAttribute('class', 'input-checkbox');
         $dependency->setValueOptions($documentTypeCollection->getSelect());
         $fieldsets->add($dependency);
     }
     $this->add($fieldsets);
     return $fieldsets;
 }
 public function testDisableEscapeHtmlHelper()
 {
     $element = new MultiCheckboxElement('foo');
     $element->setLabelOptions(array('disable_html_escape' => true));
     $element->setValueOptions(array(array('label' => '<span>label1</span>', 'value' => 'value1')));
     $markup = $this->helper->render($element);
     $this->assertRegexp('#<span>label1</span>#', $markup);
 }
Beispiel #17
0
 public function testShowErrorInMultiCheckbox()
 {
     $element = new Element\MultiCheckbox('hobby');
     $element->setLabel("Hobby");
     $element->setValueOptions(array('0' => 'working', '1' => 'coding'));
     $element->setMessages(array('Error message'));
     $markup = $this->helper->__invoke($element);
     $this->assertContains('<ul><li>Error message</li></ul>', $markup);
 }
Beispiel #18
0
 public function testOptionValueinSelectedOptions()
 {
     $element = new MultiCheckboxElement();
     $element->setValueOptions(array('Option 1' => 'option1', 'Option 2' => 'option2', 'Option 3' => 'option3'));
     $optionValue = 'option3';
     $selectedOptions = array('option1', 'option3');
     $element->setValue($selectedOptions);
     $this->assertTrue(in_array($optionValue, $element->getValue()));
 }