Answer the question
In order to leave comments, you need to log in
How to get data from DatePicker in Yii2?
Good afternoon! I select the FROM and TO dates of the Datepicker widget, I click on the form button and I want the data from the widget to be substituted as parameters for a query to display a table with data. Tell me how to get data from the DatePicker widget and process it in the controller? how to describe the model?
<?php
$form = ActiveForm::begin();
echo '<label class="control-label">Select date range</label>';
echo DatePicker::widget([
'model' => $model,
'attribute' => 'from_date',
'attribute2' => 'to_date',
'options' => ['placeholder' => 'Start date'],
'options2' => ['placeholder' => 'End date'],
'type' => DatePicker::TYPE_RANGE,
'form' => $form,
'pluginOptions' => [
'format' => 'yyyy-mm-dd',
'autoclose' => true,
]
]);
?>
<div>
<button class="btn btn-success" type="submit">Go!</button>
</div>
<?php ActiveForm::end(); ?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question