Answer the question
In order to leave comments, you need to log in
City search validation in yii 1?
Hello. It is not entirely clear, the validation system in yii1 and how it can be used in my case. What would be the best way to do this?
In layouts/main.php I have a search form:
<form action="" method="POST" id="select_city">
<input type="text" name="referal" class="who" onclick="check()" required>
<input type="submit" name="submit" value="Выбрать" class="searchCity">
</form>
if(isset($_POST['submit'])) {
$selectedCityId = $_POST['referal'];
$cookie = new CHttpCookie('referal', $selectedCityId);
Yii::app()->request->cookies['referal'] = $cookie;
}
Answer the question
In order to leave comments, you need to log in
If there are few cities, replace the textbox with a selectbox with all possible cities. If there is a lot - use a widget, for example, select2.
Well, it’s better to store the city not with text, but with id.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question