当前位置: 首页>>代码示例>>PHP>>正文


PHP SearchForm::setAttributes方法代码示例

本文整理汇总了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)]);
         }
     }
 }
开发者ID:RexGalicie,项目名称:yupe,代码行数:11,代码来源:CatalogController.php

示例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()))]);
     }
 }
开发者ID:RonLab1987,项目名称:43berega,代码行数:12,代码来源:CatalogController.php

示例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));
 }
开发者ID:hit-shappens,项目名称:testapp,代码行数:24,代码来源:BooksController.php

示例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);
         }
     }
 }
开发者ID:alexanderkuz,项目名称:test-yii2,代码行数:34,代码来源:CatalogController.php


注:本文中的SearchForm::setAttributes方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。