wop_nuno
(Wop Nuno)
1
Hello everyone,
I’m fairly new to the Yii2 framework, so I’m having some issues solving this simple problem.
I’m using the datepicker of dosamigos.
My code looks something like this:
<?= $form->field($model, ‘Data_entrada’)->widget(
DatePicker::className(), [
// inline too, not bad
'language' => 'pt',
'inline' => false,
'options' => ['placeholder' => 'Escolha a data de entrada ...'],
// modify template for custom rendering
//'template' => '<div class="well well-sm" style="background- color: #fff; width:250px">{input}</div>',
'clientOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'format' => 'yyyy-mm-dd'
]
]);?>
My input field is long, so I wanted to change the width of the field to something like 200px.
Can you tell me how to do it?
Thank you.
PS- If I uncomment the line in the code it does make the field shorter, the problem is that the "icon" for the calendar disapears.
joji
(Jojimltm)
2
Just add -> [color=#1C2837][size=2]‘options’ => [‘placeholder’ => ‘Escolha a data de entrada …’,‘style’=>‘width:200px;’],[/size][/color]
wop_nuno
(Wop Nuno)
3
Hi Joji,
Thanks for the reply.
I had already tried that, but it doesn´t work quiet well, has you can see by the screenshot in attachment.
The field does reduce to the size I want, but the calendar icon doesn’t.
6991

joji
(Jojimltm)
4
Try this
<div class="row">
<div class="col-lg-4">
<?= $form->field($model, 'Data_entrada')->widget(
DatePicker::className(), [
// inline too, not bad
'language' => 'pt',
'inline' => false,
'options' => ['placeholder' => 'Escolha a data de entrada ...'],
// modify template for custom rendering
//'template' => '<div class="well well-sm" style="background- color: #fff; width:250px">{input}</div>',
'clientOptions' => [
'autoclose' => true,
'todayHighlight' => true,
'format' => 'yyyy-mm-dd'
]
]);?>
</div>
</div>
snathan
(snathan)
6
I did not quite understand the solution provided here. But the answer is fairly straight forward. Just specify the style as one of the options.
‘options’ => [‘style’=>‘width:120px;’, ‘class’ => ‘form-control’,],