Beispiel #1
0
 private function renderFormFieldContent($renderApi, $unit)
 {
     $this->formSubmit = new \FormSubmit();
     $fieldId = 'field' . $unit->getId();
     $properties = $unit->getFormValues();
     $labelText = $properties["fieldLabel"];
     $listType = $properties["listType"];
     //select, checkbox, radio
     $postRequest = $this->getPostValue($unit);
     $choiceBox = new \ChoiceBox();
     if ($listType === \ListType::RADIO || $listType === \ListType::CHECKBOX) {
         $required = $renderApi->getFormValue($unit, 'enableRequired');
         $formField = $choiceBox->getRadioCheckbox($renderApi, $unit, $fieldId, $postRequest, $required);
     } elseif ($listType === \ListType::DROP_DOWN) {
         $formField = $choiceBox->getSelectField($renderApi, $unit, $fieldId, $postRequest);
     }
     $label = new \Label();
     $labelProperties = $label->getElementProperties();
     $labelProperties->addAttribute("for", $fieldId);
     $label->add(new \Span($labelText));
     if ($formField) {
         $elementProperties = $formField->getElementProperties();
         $wrapper = new \Container();
         $wrapper->add($label);
         $wrapper->add($formField);
         echo $wrapper->renderElement();
     }
     $renderApi->renderChildren($unit);
 }
Beispiel #2
0
 /**
  * @covers ChoiceBox::getSelectField
  */
 public function testGetEmptySelectField()
 {
     $this->setUnit('select');
     $this->object->setListOptions($this->getEmptyListOptionsMock());
     $result = $this->object->getSelectField($this->renderAPI, $this->unit, 'fieldMUNIT-2222222-22222-22222222-MUNITfield');
     $this->assertInstanceOf('SelectField', $result);
     $this->assertEquals('<select  name="fieldMUNIT-2222222-22222-22222222-MUNITfield" id="fieldMUNIT-2222222-22222-22222222-MUNITfield"></select>', $result->renderElement());
 }