10

I am trying to make the text box of jui DatePicker in Yii2 look more like the other text boxes, by adding 'form-control' to the class name of the input control, when rendered.

I tried using clientOptions like this...

'clientOptions' => [ 'class' => 'form-control' ]

'clientOptions' => [ 'className' => 'form-control' ]

...and also as widget options, but am unable to figure this out.

Compared to Bootstrap Datetimepicker, the jui one looks really ugly.

Any ideas how I can add a class or make it look like other textboxes?

I have a simple datepicker, no fancy formattings, but am using it in my model.

3 Answers 3

25

Figured it out. It was simply...

'options' => ['class' => 'form-control']
1
  • thanks! i'm surprised this was such an obscure thing to find Commented Mar 10, 2021 at 0:40
0

It may be given like this.

<?= $form->field($model, 'client_name')->widget(
                    \yii\jui\AutoComplete::classname(), 
                    [
                        'options' => ['class' => 'form-control'],
                        'clientOptions' => [
                            'source' => ['USA', 'RUS'],
                        ],
                    ]
                )?>
0

I came across the same problem but

'options' => ['class' => 'form-control']

did not work for me. I resulted to using the CHtml argument called $htmlOptions which is basically an array that holds the attributes of the HTML element and it worked for me.

'htmlOptions'=>array('class'=>'form-control')

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.