E
E
EVOSandru62015-12-31 03:32:17
Yii
EVOSandru6, 2015-12-31 03:32:17

How to change the search() of the model for a particular case in yii1?

Good afternoon,
There is such a task:
There are 2 actions in the Bids Controller (Applications)

public function actionIndex()
  {

    $model=new Bids('search');
    $model->unsetAttributes();
    if(isset($_GET['Bids']))
      $model->attributes=$_GET['Bids'];

    $this->render('admin',
    [
      'model'=>$model,
    ]);
  }

Everything is transparent here, the search method is taken from the Bids model :
public function search()
  {
    $criteria = new CDbCriteria;
    $criteria->compare('id',				$this->id);
    $criteria->compare('date_start',		$this->date_start);
    $criteria->compare('customer_id',		$this->customer_id);
    $criteria->compare('manager_id',		$this->manager_id);
    $criteria->compare('group_id',			$this->group_id);
    $criteria->compare('name',				$this->name,true);
    $criteria->compare('status_id',			$this->status_id);
    $criteria->addCondition("exist!=".ActiveRecord::EXIST_TRASH);
    $criteria->order = 'date_start DESC';
    return new CActiveDataProvider($this,
      [
        'criteria' => $criteria,
      ]);
  }

There is a need to Create a separate grid in the actionArchiv of the BidsController so that only those records that have the property status_id = '1' are displayed there.
I suspect that the actionArchiv will almost exactly repeat the actionIndex , but somehow you need to change the search () method for this action , i.e. this won't work anymore: $model=new Bids('search');
It is also important that when searching in the grid in actionArchiv , only records with a single status are searched.
Tell me what to do with search ? Thought about creating a new model with a new search, but this is probably bydlokod.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Bay, 2015-12-31
@kawabanga

There likely and at users different accesses? Personally, I would divide it into different actions/modules.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question