Skip to content

Commit

Permalink
Merge pull request #3 from Mubat/master
Browse files Browse the repository at this point in the history
Fix defauilt options initialization
  • Loading branch information
Igor Chepurnoy authored Dec 31, 2016
2 parents c083086 + d0ac7a3 commit 1009328
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions ChosenSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@
class ChosenSelect extends InputWidget
{
/**
* @var array the HTML attributes for the input tag.
* @var array the HTML attributes for the input tag. In default it contains ['data-placeholder' => 'Please select...', 'multiple' => false]
* @see \yii\helpers\Html::renderTagAttributes() for details on how attributes are being rendered.
*/
public $options = ['data-placeholder' => 'Please select...', 'multiple' => false];
public $options = [];

/**
* @var array select items
*/
public $items = [];

/**
* @var array Plugin options
* @var array Plugin options. In default it contains ['width' => '100%']
*/
public $pluginOptions = ['width' => '100%'];
public $pluginOptions = [];

/**
* Initializes the object.
Expand All @@ -38,6 +38,16 @@ class ChosenSelect extends InputWidget
public function init()
{
parent::init();

if(empty($this->options['data-placeholder'])) {
$this->options['data-placeholder'] = 'Please select...';
}
if(empty($this->options['multiple'])) {
$this->options['multiple'] = false;
}
if(empty($this->pluginOptions['width'])) {
$this->pluginOptions['width'] = '100%';
}
}

/**
Expand Down

0 comments on commit 1009328

Please sign in to comment.