本文整理汇总了PHP中SearchForm::setAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP SearchForm::setAttributes方法的具体用法?PHP SearchForm::setAttributes怎么用?PHP SearchForm::setAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SearchForm
的用法示例。
在下文中一共展示了SearchForm::setAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionSearch
public function actionSearch()
{
if (Yii::app()->getRequest()->getQuery('SearchForm')) {
$form = new SearchForm();
$form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
if ($form->validate()) {
$category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
$this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->search($form->q, $form->category)]);
}
}
}
示例2: actionSearch
public function actionSearch()
{
if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
throw new CHttpException(404);
}
$form = new SearchForm();
$form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
if ($form->validate()) {
$category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
$this->render('search', ['category' => $category, 'searchForm' => $form, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
}
}
示例3: actionList
/**
* Show all books.
*/
public function actionList()
{
$criteria = new CDbCriteria();
$criteria->with = 'author';
$searchForm = new SearchForm();
if (isset($_POST['SearchForm'])) {
$searchForm->setAttributes($_POST['SearchForm']);
$criteria = $searchForm->apllyFilter($criteria);
}
$pages = new CPagination(Books::model()->count());
$pages->applyLimit($criteria);
$sort = new CSort('Books');
$sort->attributes = array('name', 'date', 'date_update', 'author' => array('asc' => 'author.lastname, author.firstname', 'desc' => 'author.lastname DESC, author.firstname DESC', 'label' => 'Автор'));
$sort->defaultOrder = 'name';
$sort->applyOrder($criteria);
$books = Books::model()->findAll($criteria);
$formWidget = $this->createWidget('FormWindow');
$formWidget->afterClose = '$("#ui-datepicker-div").remove();$("#content").load("#");';
$formWidget->run();
$this->renderAjax('list', array('pages' => $pages, 'models' => $books, 'sort' => $sort, 'searchForm' => $searchForm));
}
示例4: actionSearch
public function actionSearch()
{
if (!Yii::app()->getRequest()->getQuery('SearchForm')) {
throw new CHttpException(404);
}
$form = new SearchForm();
$form->setAttributes(Yii::app()->getRequest()->getQuery('SearchForm'));
if ($form->validate()) {
$category = $form->category ? StoreCategory::model()->findByPk($form->category) : null;
$countries['list'] = [];
$countries['checked'] = [];
$price['minValue'] = [];
$price['maxValue'] = [];
//$countries['list'] = $this->productRepository->getCountriesFilter($form->q);
if (Yii::app()->request->getQuery('strana')) {
foreach (Yii::app()->request->getQuery('strana') as $item) {
$countries['checked'] += [$item => $item];
}
}
$price = $this->productRepository->getPricesFilter($form->q);
if (Yii::app()->request->getQuery('minPrice')) {
$price['minValue'] = Yii::app()->request->getQuery('minPrice');
}
if (Yii::app()->request->getQuery('maxPrice')) {
$price['maxValue'] = Yii::app()->request->getQuery('maxPrice');
}
$this->render('search', ['category' => $category, 'searchForm' => $form, 'price' => $price, 'countries' => $countries, 'dataProvider' => $this->productRepository->getByFilter($this->attributeFilter->getMainAttributesForSearchFromQuery(Yii::app()->getRequest(), [AttributeFilter::MAIN_SEARCH_PARAM_NAME => $form->q]), $this->attributeFilter->getEavAttributesForSearchFromQuery(Yii::app()->getRequest()))]);
} else {
if ($form->category) {
$category = StoreCategory::model()->findByPk($form->category);
$this->redirect('/store/' . $category->type);
}
}
}