本文整理匯總了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);
}
}
}