Example #1
0
 public function testAddTextarea()
 {
     $tpl = Di::getDefault()->get('template');
     $form = new Form('testForm');
     $arr = array('type' => 'textarea', 'label' => 'Test', 'name' => 'testTextarea', 'mandatory' => false);
     $form->addStatic($arr);
     $sm = $form->toSmarty();
     $tpl->assign('form', $sm['testTextarea']['html']);
     $printedResult = $tpl->fetch($this->formTpl);
     $this->assertContains('<div class="form-group "><div class="col-sm-2" style="text-align:right">' . '<label class="label-controller" for="testTextarea">Test</label></div>' . '<div class="col-sm-9">' . '<textarea id="testTextarea" ' . 'name="testTextarea" class="form-control " rows="3" placeholder="testTextarea" >' . ' </textarea></div></div>', $printedResult);
 }
Example #2
0
 /**
  * 
  * @param array $step
  * @param array $fName
  * @param array $value List of default values
  * @return array
  */
 private function buildFormComponents($step, &$fName, $values)
 {
     $myForm = new Form('pollerTemplate');
     foreach ($step as $field) {
         $fName[] = $field['name'];
         $attributes = array();
         if (isset($field['attributes'])) {
             $attributes = json_encode($field['attributes']);
         }
         $mandatory = 1;
         if (isset($field['require']) && false === $field['require']) {
             $mandatory = 0;
         }
         $formField = array('name' => $field['name'], 'label' => $field['label'], 'type' => $field['type'], 'mandatory' => $mandatory, 'attributes' => $attributes);
         $myForm->addStatic($formField);
     }
     $myForm->setDefaults($values);
     $formComponents = $myForm->toSmarty();
     unset($myForm);
     return $formComponents;
 }