I have a widget that displays charts. I want user to select the type of chart usign drop down (column bar pie etc)
I am trying to pass selected item from dropdown ActiveForm to my ChartsWidget.
How do I sent data from dropdown to ChartsWidget class. How do I get that item on my ChartsWidget Class???
This is the view for dropdown.
<div class="type-search" style="float: left; width: 48%;">
<?php
$form = ActiveForm::begin([
'action' => ['type'],
'method' => 'get',
]);
$data = ["column", "bar", "pie"];
echo '<label class="control-label">Tipo</label>';
echo Select2::widget([
'name' => 'state_10',
'data' => $data,
'options' => [
'placeholder' => 'Selecciona un tipo'
],
]);
?>
<div class="form-group">
<?= Html::submitButton('Search', ['class' => 'btn btn-primary']) ?>
<?= Html::resetButton('Reset', ['class' => 'btn btn-default']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
In a normal view I use
$form = ActiveForm::begin([
'action' => ['type'],
'method' => 'get',
]);
to send data (obviously ChartsWidget has no action due it is not a controller).
And I can use
$query = Yii::$app->request->queryParams;
to get data in controller.
How do I do the same but in widget???