/** * wizard para inclusao de elementos no form * * @param string $txLabel * @param ElementAbstract|string $element * @param boolean $isRequired * @param string $posLegend * @param boolean * @return ScreenFormForm * */ public function wAdd($txLabel, $element, $isRequired = FALSE, $posLegend = NULL, $returnCreatedElem = FALSE) { $divCtlGroup = Div::factory()->addClass('control-group'); $divCtrls = Div::factory()->addClass('controls'); if (!$element instanceof ElementAbstract) { $element = Text::factory($element); } $for = $element->getAttr('id') ?: $element->getAttr('name'); $label = Label::factory(NULL, $for)->addClass('control-label'); $divCtlGroup->add(array($label, $divCtrls)); if (TRUE == $isRequired) { $element->addClass('required'); $span = Span::factory()->addClass('required')->setContent(self::T_SCRENFORMFORM_REQUIRED_TOKEN); $label->add($span); } $label->add(Text::factory($txLabel)); $divCtrls->add($element); if (NULL != $posLegend) { if (!$posLegend instanceof ElementAbstract) { $posLegend = Text::factory(' ' . $posLegend); } $divCtrls->add($posLegend); } if ($returnCreatedElem) { return $divCtlGroup; } $this->_container->add($divCtlGroup); return $this; }
/** * Grupo de Radio button ou Checkbox. * * @param string $type * @param stdClass $config * @return Fieldset * */ public function groupRadioAndCheck($type, \stdClass $config) { $fiedset = new Fieldset(isset($config->title) ? $config->title : NULL); $content = NULL; if (!isset($config->content)) { $config->content = array(); } foreach ($config->data as $elm) { $elm = (object) $elm; $elmId = $this->genId($config); $label = new Label($elm->text, $elmId); $radio = new Input($config->name, $type); $radio->value = $elm->value; $radio->id = $elmId; if (isset($elm->checked)) { $radio->checked = 'checked'; } $label->add($radio); $fiedset->add($label); } return $fiedset; }
/** * @param string $type * @param string $name * @param stdClass $elements * @param string $IDElem * @return Fieldset * */ public function GRadioOrCheckbox($type, $name, \stdClass $elements) { $fiedset = new Fieldset(); $content = NULL; foreach ($elements as $elm) { $elm = (object) $elm; $label = new Label($elm->text); $input = new Input($name, $type); $input->value = $elm->value; if (isset($elm->checked)) { $input->checked = 'checked'; } $label->add($input); $fiedset->add($label); } return $fiedset; }
/** * @param Fieldset $group * @param stdClass $property * */ public function radioAndChecGroupProperty(Fieldset $group, \stdClass $property) { if (isset($property->id)) { $group->attr('id', $property->id); } if (isset($param->title)) { $group->add(new Legend($property->title)); } }