當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。