/** * 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; }
/** * formulario de login * * @param stdClass $param * @return Form * */ public function login(\stdClass $param) { $param->name = $this->safeToggle($param, 'name', 'frmLogin'); $form = $this->form($param); $form->method = self::T_SAF_FORM_METHOD; $fiedset = Fieldset::factory()->add(new Legend($param->legend)); foreach ($param->input as $input) { $fiedset->add($this->_createControlGroupInput($input)); } $options = new \stdClass(); $options->options = $param->toolbar; $form->add($fiedset)->add($this->buttonbar($options)); return $form; }
/** * @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)); } }