public function test()
 {
     $tag = new Tag();
     $this->assertEquals('<div></div>', $tag->render());
     $tag->setTagName('a');
     $this->assertEquals('<a></a>', $tag->render());
     $tag->setAttributes(['class' => 'btn']);
     $this->assertEquals('<a class="btn"></a>', $tag->render());
     $first = new Tag();
     $first->setTagName('i')->setAttributes(['class' => 'icon']);
     $first->children()->add(new DataView('&nbsp;'));
     $second = new DataView('Hi!');
     $tag->children()->set([$first, $second]);
     $this->assertEquals('<a class="btn"><i class="icon">&nbsp;</i>Hi!</a>', $tag->render());
 }
Esempio n. 2
0
 /**
  * @param array|null $attributes
  * @param array $options components or 'value' => 'label' array
  * @param string $selectedValue
  */
 public function __construct(array $attributes = [], array $options = [], $selectedValue = null)
 {
     parent::__construct('select', $attributes, self::makeOptionComponents($options));
     if ($selectedValue !== null) {
         $this->setOptionSelected($selectedValue);
     }
 }
Esempio n. 3
0
 /**
  * TableCaption constructor.
  *
  * @param null|string $text
  * @param array $attributes caption tag attributes
  */
 public function __construct($text, $attributes = [])
 {
     parent::__construct('caption', $attributes);
     $this->setDestinationParentId(Grid::TABLE_ID);
     $this->setId(static::ID);
     $this->addChild($this->text = new DataView($text));
 }
Esempio n. 4
0
isset($labelAttributes) || ($labelAttributes = []);
isset($containerAttributes) || ($containerAttributes = []);
$inputAttributes = array_merge(['name' => $name, 'placeholder' => $placeholder, 'type' => $inputType, 'value' => $value, 'class' => $inputClass], $inputAttributes);
$containerAttributes = array_merge(['class' => $containerClass], $containerAttributes);
$labelAttributes = array_merge(['class' => $labelClass], $labelAttributes);
?>

<<?php 
echo $containerTag;
?>
 <?php 
echo Tag::renderAttributes($containerAttributes);
?>
>

<?php 
echo isset($label) ? new TagWithText('label', $label, $labelAttributes) . '&nbsp;' : '';
?>

<input <?php 
echo Tag::renderAttributes($inputAttributes);
?>
/>
<?php 
echo $component->renderChildren();
?>
</<?php 
echo $containerTag;
?>
>
 /**
  * TagWithText constructor.
  *
  * @param string $tagName html tag name, optional, default value: 'div'
  * @param string $text tag contents (optional)
  * @param array $attributes html tag attributes (optional)
  */
 public function __construct($tagName = 'div', $text = '', array $attributes = [])
 {
     parent::__construct($tagName, $attributes, [$this->textComponent = new DataView($text)]);
 }
Esempio n. 6
0
$labelAttributes = array_merge(['class' => $labelClass], $labelAttributes);
// support of auto-submitting form on value change
if (isset($autoSubmit) && $autoSubmit === true) {
    if (array_key_exists('onchange', $inputAttributes)) {
        $inputAttributes['onchange'] .= ';this.form.submit();';
    } else {
        $inputAttributes['onchange'] = 'this.form.submit()';
    }
}
?>

<<?php 
echo $containerTag;
?>
 <?php 
echo Tag::renderAttributes($containerAttributes);
?>
>

<?php 
echo isset($label) ? new TagWithText('label', $label, $labelAttributes) : '';
?>

<?php 
echo new Select($inputAttributes, $options, $value);
?>
</<?php 
echo $containerTag;
?>
>