/** * Renders out an optgroup and any child options * * @param Render $renderer * * @return string * * @since 2.0 */ public function render(Render $renderer) { $content = ''; foreach ($this->getContents() as $option) { $content .= "\n" . $renderer->render($option); } return Html::tag('optgroup', $this->getAttributes(), $content); }
/** * Should return a html string that represents the rendered object * * @param Render $renderer * * @return string * * @since 2.0 */ public function render(Render $renderer) { $elements = ''; foreach ($this->getContents() as $element) { $elements .= "\n" . $renderer->render($element); } return Html::tag('form', $this->getAttributes(), $elements); }
/** * Renders the Fieldset to html * * @param Render $renderer * * @return string * * @since 2.0 */ public function render(Render $renderer) { $legend = ''; //Make sure the legend is added if needed if (!is_null($this->getLegend())) { $legend = Html::tag('legend', [], $this->getLegend()); } //Makes sure the legend is added if one exists $elements = $legend; //Render all the elements foreach ($this->getContents() as $element) { $elements .= "\n" . $renderer->render($element); } return Html::tag('fieldset', $this->getAttributes(), $elements); }
/** * Helper function to convert an array into a list of attributes and append * them to a string * * @param string $html * @param array $attributes */ protected function addAttributes(&$html, array $attributes) { if (count($attributes) > 0) { $attributes = Html::arrayToAttributes($attributes); $html .= ' ' . $attributes; } }
/** * Renders a generic input * * @param Render $renderer * * @return string "<input type="..." * * @since 2.0 */ public function render(Render $renderer) { return Html::tag('input', $this->getAttributes(), $this->getContents()); }
/** * @covers Fuel\Common\Html::arrayToAttributes * @group Common */ public function testTagWithAttributesThatNeedEncoding() { $this->assertEquals('name="blue & green"', Html::arrayToAttributes(array('name' => 'blue & green'))); }
/** * Renders a submit with the appropriate classes. * * @param Submit $select * * @return string */ public function renderSubmit(Submit $select) { $attributes = $select->getAttributes(); if (!isset($attributes['class'])) { $attributes['class'] = ''; } $attributes['class'] .= ' btn btn-default'; return Html::tag('button', $attributes, $select->getValue()); }
/** * Renders the whole form, wrapping a table in <form> tags. * * @param Form $form * * @return string * * @since 2.0 */ public function renderForm(Form $form) { foreach ($form as $element) { $this->render($element); } $tableRender = new SimpleTable(); $tableContent = $tableRender->renderTable($this->table); return Html::tag('form', $form->getAttributes(), $tableContent); }