I can not use ActiveForm widget, but I have form model setup, and I am rendering most of my html using HTML class.
So my view is mixture of HTML wrappers for html fields and plain html because I couldn’t make it work through wrappers.
My question is how to display errors ?
This is the part of my view:
<?php
$post = Yii::$app->request->post();
foreach ($post as $key => $value) {
if (!empty($value)) {
$$key = $value;
} else {
$$key = null;
}
}
?>
<input type="text" value="<?= (isset($searchField) ? $searchField : '') ?>" name="searchField" class="search-fieldEvent" style="background-image: url(images/searchButtonGlobal0.png); background-repeat:no-repeat;
background-position: 310px 7px; cursor: pointer;"/>
<?= HTML::dropDownList('eventType', ['value' => (isset($eventType)) ? $eventType : '0'],
LookupHelper::eventCategories(), ['class' => 'dropDownL']) ?>
<?= DatePicker::widget([
'name' => 'from_date',
'value' => (isset($from_date) ? $from_date : date('d.m.Y')),
'language' => Yii::$app->language,
'dateFormat' => 'php:d.m.Y',
'options' => ['class' => 'datepicker-here datePickEvent' , 'id' => 'fromElement']
]); ?>
How can I validate these fields: searchField, eventType and from_date ? Also, as you can see I am trying to keep old values in form after the form is submitted, so user can see what he has typed.
Does anyone have some guide on how to do this a bit better ?