function testAttrConvert() { $exp = array('class' => 'test'); $this->assertEquals($exp, HTML::AttrConvert('test'), 'Если передан не массив - он становится классом'); $arr1 = array('two' => 2, 'one' => 1); $exp = array('one' => 1, 'two' => 2); $this->assertEquals($exp, HTML::AttrConvert($arr1), 'Атрибуты сортируются по алфавиту'); $arr2 = array('three' => 3); $exp = array('class' => 'hello', 'one' => 1, 'two' => 2, 'three' => 3); $this->assertEquals($exp, HTML::AttrConvert($arr1, 'hello', $arr2), 'Объединение нескольких групп атрибутов'); }
/** Атрибуты тега формы */ public function getFormAttributes($attr = null) { $a = HTML::AttrConvert($attr ?: $this->form_attributes); if ($this->name) { $a['id'] = 'form-' . $this->name; } return $a; }
/** Массив атрибутов для HTML тега инпута */ public function getAttributes($include_placeholder = true) { $arr = array('id' => $this->getId()); if ($include_placeholder) { $arr['placeholder'] = $this->getPlaceholder(); } return HTML::AttrConvert($this->attributes, $arr); }