Example #1
0
 /**
  * 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);
 }
Example #2
0
 /**
  * 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);
 }
Example #3
0
 /**
  * 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);
 }
Example #4
0
 /**
  * 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;
     }
 }
Example #5
0
 /**
  * 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());
 }
Example #6
0
 /**
  * @covers Fuel\Common\Html::arrayToAttributes
  * @group Common
  */
 public function testTagWithAttributesThatNeedEncoding()
 {
     $this->assertEquals('name="blue &amp; green"', Html::arrayToAttributes(array('name' => 'blue & green')));
 }
Example #7
0
 /**
  * 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());
 }
Example #8
0
 /**
  * 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);
 }