Hi there, i’m trying to use the select option to create an event with a Modal with the selected date using Full Calendar - Philippfrenzel but i don’t know how.
I already have an event Click wich works but that it’s not what i really want.
**Controller:**
public function actionRequisitar(){
$searchModel= new RequisicaoSearch();
$dataProvider = $searchModel->search(Yii::$app->request->queryParams);
$events = [];
foreach(Requisicao::find()->all() as $requisicao){
$event = new \yii2fullcalendar\models\Event();
$event->id = $requisicao->id;
$event->title = $requisicao->motivo_requisicao;
$event->start = $requisicao->data_inicio_req;
$events[] = $event;
}
return $this->render('requisitar',[
'events'=>$events,
'searchModel' => $searchModel,
'dataProvider' => $dataProvider,
]);
}
public function actionCreate()
{
$model = new Requisicao();
//$model->data_inicio_req=$date;
if ($model->load(Yii::$app->request->post()) && $model->save()) {
return $this->redirect(['view', 'id' => $model->id, 'utilizador_id' => $model->utilizador_id, 'sala_id' => $model->sala_id]);
}
return $this->renderAjax('create', [
'model' => $model,
]);
}
**Index:**
<?= \yii2fullcalendar\yii2fullcalendar::widget(array(
'events' => $events,
'id' => 'calendar',
));
?>
**Main.js**
$(function () {
$('#modalButton').click(function () {
$('#modal').modal('show')
.find('#modalContent')
.load($(this).attr('value'));
});
$(document).on('click', '.fc-day', function () {
var date = $(this).attr('data-date');
$.get('index.php?r=requisicao/create', {'date': date}, function (data) {
$('#modal').modal('show')
.find('#modalContent')
.load(data);
});
});
});
Thank you for your time.