Skip to content

Tabular Steps (New Feature)

Coackroach edited this page Mar 2, 2020 · 10 revisions

A new feature for tabular steps has been added which will help you to configure address book like features into the formwizard, there have been several queries related to such feature where we need to add multiple addresses against a single user or add multiple tags against any album and we need to be able to have a Add New button which should dynamically add the set of inputs as needed you can use the type property in the step array, it defaults to default. See the details below under options.

After the addition of the feature Tabular Steps when using 'type'=>'tabular' you must remember that you cannot provide different models, although you can provide multiple instances when in edit mode but for the same model only.

New Constants added are

    const STEP_TYPE_DEFAULT='default';
    const STEP_TYPE_TABULAR='tabular';

While adding a new record you can have like below

    $addressModel = new Address();

    "steps"=>[
      [
        'title'=>'Step Title',
        'type' => FormWizard::STEP_TYPE_TABULAR,
        'model'=> $addressModel
      ]
    ]

When in Edit Mode you can provide the multiple instances of Address

    //either using model directly
      $addressModel = Address::find()
          ->where(
            ['=','user_id',Yii::$app->user->id]
          )->all();

      //or using the model relation if you have `getAddress()` defined inside
      //the `User` model. `$user` has the selected user in code below
      $addressModel = $user->address;

    "steps"=>[
      [
          'title'=>'Step Title',
          'type' => FormWizard::STEP_TYPE_TABULAR,
          'model'=> $addressModel
      ]
    ]
Clone this wiki locally