protected function optgroupNest($data) { $html = new Html(); foreach ($data as $nest) { $nested = isset($nest['subs']) && !empty($nest['subs']) ? $this->optgroupNest($nest['subs']) : ''; $html->tag('optgroup'); isset($nest['class']) && $nest['class'] ? $html->class($nest['class']) : false; $html->label($nest['label']); foreach ($nest['options'] as $option) { $html->tag('option'); isset($option['class']) && $option['class'] ? $html->class($option['class']) : false; isset($option['value']) ? $html->value($option['value']) : false; isset($option['selected']) && $option['selected'] ? $html->selected() : false; $html->text($option['text']); $html->tag(); } $html->append($nested); $html->tag(); } return $html->give(); }
public function body($fields) { if (isset($fields['fields'])) { $fields = $fields['fields']; } $html = new Html(); if (!empty($fields)) { foreach ($fields as $field) { $for = uniqueID(); $forfrom = $for . '-from'; $forto = $for . '-to'; $html->tag('div'); isset($field['error']) && $field['error'] ? $html->class('form-group row has-danger') : $html->class('form-group row'); $html->tag('label')->for($for)->class('col-xs-2 col-form-label')->text($field['label']); isset($field['extra']) && $field['extra'] ? $html->jsData('show', $for) : false; $html->tag(); $html->tag('div')->class('col-xs-6'); if (isset($field['prefix']) && $field['prefix'] || isset($field['postfix']) && $field['postfix']) { $html->tag('div')->class('input-group'); if (isset($field['prefix']) && $field['prefix']) { $html->tag('span')->class('input-group-addon')->text($field['prefix'])->tag(); } } /* START SELECT */ if ($field['type'] == 'menu') { $html->tag('select')->id($for); isset($field['onredirectvalue']) && $field['onredirectvalue'] ? $html->jsData('onredirectvalue', $field['onredirectvalue'] . '?' . $field['caption']) : false; isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; if (isset($field['top_label']) && $field['top_label']) { $html->tag('option')->value()->text($field['top_label'])->tag(); } foreach ($field['options'] as $option) { $html->tag('option'); isset($option['value']) ? $html->value($option['value']) : false; isset($option['selected']) && $option['selected'] ? $html->selected() : false; $html->text($option['text']); $html->tag(); } $html->tag(); } /* END SELECT */ /* START MULTISELECT */ if ($field['type'] == 'multiselect') { $html->tag('select')->id($for); isset($field['caption']) && $field['caption'] ? $html->name($field['caption'] . '[]') : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->multiple(); foreach ($field['options'] as $option) { $html->tag('option'); $html->value($option['value']); isset($option['selected']) && $option['selected'] ? $html->selected() : false; $html->text($option['text']); $html->tag(); } $html->tag(); } /* END MULTISELECT */ /* START OPTGROUP */ if ($field['type'] == 'optgroup') { $html->tag('select')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->append($html->tool('nested')->optgroup($field['options'])); $html->tag(); } /* END OPTGROUP */ /* START TEXTAREA */ if ($field['type'] == 'textarea') { $html->tag('textarea')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['rows']) && $field['rows'] ? $html->rows($field['rows']) : $html->rows(5); isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->text($field['value']); $html->tag(); } /* END TEXTAREA */ /* START INPUT */ if ($field['type'] == 'input') { /* START TEXT */ if ($field['ctype'] == 'text') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } /* END TEXT */ /* START EMAIL */ if ($field['ctype'] == 'email') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } /* END EMAIL */ /* START PASSWORD */ if ($field['ctype'] == 'password') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } /* END PASSWORD */ /* START URL */ if ($field['ctype'] == 'url') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } /* END URL */ /* START DATE */ if ($field['ctype'] == 'date') { if (isset($field['double']) && $field['double']) { $html->tag('div'); isset($field['from']['error']) && $field['from']['error'] ? $html->class('form-group has-error') : $html->class('form-group'); $html->style('margin-bottom:8px'); $html->tag('label')->for($forfrom)->text($field['from']['label']); isset($field['extra']) && $field['extra'] ? $html->jsData('show', $forfrom) : false; $html->tag(); if (isset($field['from']['prefix']) && $field['from']['prefix'] || isset($field['from']['postfix']) && $field['from']['postfix']) { $html->tag('div')->class('input-group'); if (isset($field['from']['prefix']) && $field['from']['prefix']) { $html->tag('span')->class('input-group-addon')->text($field['from']['prefix'])->tag(); } } $html->tag('input')->id($forfrom); isset($field['from']['style']) && $field['from']['style'] ? $html->style($field['from']['style']) : false; isset($field['from']['ctype']) && $field['from']['ctype'] ? $html->type($field['from']['ctype']) : false; isset($field['from']['caption']) && $field['from']['caption'] ? $html->name($field['from']['caption']) : false; isset($field['from']['class']) && $field['from']['class'] ? $html->class($field['from']['class']) : false; $html->value($field['from']['value']); $html->tag(); isset($field['from']['error']) && $field['from']['error'] ? $html->tag('span')->class('help-block')->text($field['from']['error'])->tag() : false; isset($field['from']['msg_info']) && $field['from']['msg_info'] ? $html->tag('span')->class('help-block')->text($field['from']['msg_info'])->tag() : false; $html->tag(); $html->tag('div'); isset($field['to']['error']) && $field['to']['error'] ? $html->class('form-group has-error') : $html->class('form-group'); $html->style('margin-bottom:8px'); $html->tag('label')->for($forto)->text($field['to']['label']); isset($field['extra']) && $field['extra'] ? $html->jsData('show', $field['to']['caption']) : false; $html->tag(); if (isset($field['to']['prefix']) && $field['to']['prefix'] || isset($field['to']['postfix']) && $field['to']['postfix']) { $html->tag('div')->class('input-group'); if (isset($field['to']['prefix']) && $field['to']['prefix']) { $html->tag('span')->class('input-group-addon')->text($field['to']['prefix'])->tag(); } } $html->tag('input')->id($forto); isset($field['to']['style']) && $field['to']['style'] ? $html->style($field['to']['style']) : false; isset($field['to']['ctype']) && $field['to']['ctype'] ? $html->type($field['to']['ctype']) : false; isset($field['to']['caption']) && $field['to']['caption'] ? $html->name($field['to']['caption']) : false; isset($field['to']['class']) && $field['to']['class'] ? $html->class($field['to']['class']) : false; $html->value($field['to']['value']); $html->tag(); isset($field['to']['error']) && $field['to']['error'] ? $html->tag('span')->class('help-block')->text($field['to']['error'])->tag() : false; isset($field['to']['msg_info']) && $field['to']['msg_info'] ? $html->tag('span')->class('help-block')->text($field['to']['msg_info'])->tag() : false; $html->tag(); } else { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } } /* END DATE */ /* START COLOR */ if ($field['ctype'] == 'color') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; $html->value($field['value']); $html->tag(); } /* END COLOR */ /* START CHECKBOX */ if ($field['ctype'] == 'checkbox') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; isset($field['checked']) && $field['checked'] ? $html->checked() : false; $html->tag(); } /* END COLOR */ /* START CHECKBOX */ if ($field['ctype'] == 'radio') { $html->tag('input')->id($for); isset($field['style']) && $field['style'] ? $html->style($field['style']) : false; isset($field['ctype']) && $field['ctype'] ? $html->type($field['ctype']) : false; isset($field['caption']) && $field['caption'] ? $html->name($field['caption']) : false; isset($field['class']) && $field['class'] ? $html->class($field['class']) : false; isset($field['checked']) && $field['checked'] ? $html->checked() : false; $html->tag(); } /* END COLOR */ } /* END INPUT */ /* END TYPES */ if (isset($field['prefix']) && $field['prefix'] || isset($field['postfix']) && $field['postfix']) { if (isset($field['postfix']) && $field['postfix']) { $html->tag('span')->class('input-group-addon')->text($field['postfix'])->tag(); } $html->tag(); } isset($field['error']) && $field['error'] ? $html->tag('div ')->class('form-control-feedback')->text($field['error'])->tag() : false; isset($field['msg_info']) && $field['msg_info'] ? $html->tag('div')->class('form-text text-muted')->text($field['msg_info'])->tag() : false; $html->tag(); $html->tag(); if (isset($field['extra']) && $field['extra']) { $html->tag('div')->class('display_none')->data('hide', $for)->text($this->body($field['extra']))->tag(); } } return $html->give(); } return false; }