/** * Renders [tagsinput](https://github.com/bootstrap-tagsinput/bootstrap-tagsinput). * @param array $options * @return $this */ public function tags($options = []) { $options['data-role'] = 'tagsinput'; $this->adjustLabelFor($options); if (!isset($options['id'])) { $options['id'] = $this->getInputId(); } $model = $this->model; $attribute = $this->attribute; $data = $model->{$attribute}; $value = ''; if (is_array($data)) { if (count($data) > 0) { if (is_object($data[0])) { $value = implode(',', ArrayHelper::objectsAttribute($data, 'title')); } else { $value = implode(',', $data); } } } else { $value = $data; } $this->parts['{input}'] = Html::textInput(Html::getInputName($model, $attribute), $value, $options); return $this; }
public function testIsAssoc() { $array = ['a' => 10, 'b' => 20, 'c' => '1']; $this->assertTrue(ArrayHelper::isAssoc($array)); $array = [10, 20, 'c' => '1']; $this->assertTrue(ArrayHelper::isAssoc($array)); $array = [10, 'b', 'c']; $this->assertFalse(ArrayHelper::isAssoc($array)); }