/** * SelectElement constructor. * @param null $name * @param array $data * @param null $selectedValue * @param array $attributes */ public function __construct($name = null, array $data = [], $selectedValue = null, array $attributes = []) { parent::__construct('select', $attributes, null); $this->setAttribute('name', $name); $this->data('selected', $selectedValue); foreach ($data as $title => $item) { if (is_array($item)) { $group = new OptgroupElement(); foreach ($item as $optionTitle => $optionValue) { $option = new OptionElement($optionTitle); $group->setAttribute('label', $title)->appendContent($option->setAttribute('value', $optionValue)); } $this->appendContent($group); } else { $option = new OptionElement($title); $this->appendContent($option->setAttribute('value', $item)); } } }
$div->appendContent($button); echo $text, $input, $password, $button, $div; echo '<hr>'; $form = new FormElement('/app/save_element.php', 'post', true, new InputSubmitElement('save!', null)); $form->addClass('form-component')->id(md5(time()))->prependContent($div->removeClass('ok'))->prependContent($text); echo $form; $tableForm = new TableElement(); $tableForm->row('Test Form!!!')->cell($form); echo '<hr>'; echo Tag::a('test', 'click me!')->addClass('col-md-12')->id('dezdezdez')->addClass('c'); echo '<hr>'; echo Tag::img('http://fox-fan.ru/news/269_1.jpg', 250, -1, 'rounded'); $select = new SelectElement('geo_list', ['Ukraine' => 'ua', 'Ukraine Regions' => ['Kiev' => 'ua-kyiv', '4e' => 'ua-4e'], 'Japan' => 'jp'], rand(0, 9)); echo $select; $optgroup = new OptgroupElement(); $optgroup->setAttribute('label', 'Test'); for ($i = 0; $i < 10; $i++) { $optgroup->appendContent((new OptionElement("Item {$i}"))->id("id-{$i}")->setAttribute('value', $i)); } $select->prependContent($optgroup); echo $select, (new ScriptElement('js/jquery.js'))->async(true); echo new InputCheckboxElement('test', 'asd'); echo new InputButtonElement('click me!!1'); $ul = new UlElement([new LiElement('Test item'), new LiElement('Test item 2'), new AElement('?test=qwerty', new LiElement('With link')), new BoldElement(new AElement('?test=qwerty', new LiElement('With link in bold')))]); $ul->appendContent(new LiElement(['inner cloned UL', clone $ul])); $ul->appendContent(new LiElement(['simple text', new AElement('?go=нахуй', [new BoldElement('ok'), new ItalicElement(new SpanElement(' -> span'))]), new ItalicElement(new BoldElement('!'))])); for ($i = 0; $i < 10; $i++) { if ($i % 3 == 0) { $ul->appendContent(new AElement("?li={$i}", new LiElement("item {$i}"))); } else { $ul->appendContent(new LiElement("item {$i}"));