예제 #1
0
파일: Element.php 프로젝트: sqrt-pro/form
 /** Подготовка атрибутов */
 protected function prepareAttr($attr, $add_placeholder = false)
 {
     if (is_null($attr)) {
         $attr = $this->getAttr();
     }
     $arr = array('id' => $this->getInputId());
     if ($add_placeholder && ($ph = $this->getPlaceholder())) {
         $arr['placeholder'] = $ph;
     }
     return array_merge($arr, Tag::MergeAttr($attr) ?: array());
 }
예제 #2
0
 /** Создание тега для вложенных опций */
 protected function renderOptionsTmpl(Tag $tag)
 {
     return sprintf($this->getOptionsTmpl(), $tag->toHTML(), $tag instanceof Checkbox ? $tag->getDisplayValue() : $tag->getValue());
 }
예제 #3
0
파일: TagTest.php 프로젝트: sqrt-pro/tag
 function testMergeAttr()
 {
     $res = Tag::MergeAttr('one', 'two');
     $exp = array('class' => 'one two');
     $this->assertEquals($exp, $res, 'Вариант 1');
     $res = Tag::MergeAttr('one', array('id' => 'two'));
     $exp = array('class' => 'one', 'id' => 'two');
     $this->assertEquals($exp, $res, 'Вариант 2');
     $res = Tag::MergeAttr(array('style' => 'border: red;'), array('class' => 'red', 'style' => 'color: green;'));
     $exp = array('style' => 'border: red; color: green;', 'class' => 'red');
     $this->assertEquals($exp, $res, 'Вариант 3');
     $res = Tag::MergeAttr(array('style' => array('width' => '15px;', 'height' => '200px')), 'red');
     $exp = array('style' => 'width: 15px; height: 200px;', 'class' => 'red');
     $this->assertEquals($exp, $res, 'Вариант 4');
 }