diff --git a/Datepicker.php b/Datepicker.php index 63d0695..92f74ae 100644 --- a/Datepicker.php +++ b/Datepicker.php @@ -44,20 +44,26 @@ class Datepicker extends InputWidget public $theme = 'default'; /** - * @var string the size of the input ('lg', 'md', 'sm', 'xs') + * @var string the size of the input ('lg', 'sm') */ public $size; /** - * @var string the addon markup if you wish to display the input as a component then set it to - * something like ''. + * @var string the prepend addon markup if you wish to display the input as a component then set it to + * something like 'Sample Text'. */ - public $addon = false; + public $prependAddon = false; + + /** + * @var string the append addon markup if you wish to display the input as a component then set it to + * something like 'Sample Text'. + */ + public $appendAddon = false; /** * @var string the template to render the input. */ - public $template = '{input}{addon}'; + public $template = '{prepend}{input}{append}'; /** * @var bool whether to render the input as an inline calendar @@ -96,9 +102,15 @@ public function run() if ($this->inline) { $input .= '
'; } - if ($this->addon && !$this->inline) { - $addon = Html::tag('span', $this->addon, ['class' => 'input-group-addon']); - $input = strtr($this->template, ['{input}' => $input, '{addon}' => $addon]); + if (($this->prependAddon || $this->appendAddon) && !$this->inline) { + $prepend = $append = ''; + if ($this->prependAddon) { + $prepend = Html::tag('span', $this->prependAddon, ['class' => 'input-group-prepend']); + } + if ($this->appendAddon) { + $append = Html::tag('span', $this->appendAddon, ['class' => 'input-group-append']); + } + $input = strtr($this->template, ['{prepend}' => $prepend, '{input}' => $input, '{append}' => $append]); $input = Html::tag('div', $input, $this->containerOptions); } if ($this->inline) {