Skip to content

Tabular Steps: Limiting Rows

Coackroach edited this page May 15, 2019 · 1 revision

When working with Tabular steps you may want to restrict the user depending on the requirements to add specific number of rows, and not any more than that. Like for example they can choose to add 3 referrals who will be sent a discount code when the user signs up or can redeem 3 coupons when using the formwizard as a shopping cart to checkout.

You can use the limitRows option inside the main options for the step in combination with the STEP_TYPE_TABULAR for instance see below example

echo FormWizard::widget([
    'steps' => [
        [
            'title'=>'Redeem Coupons'
            'model' =>  new Coupons(),
            'type' => FormWizard::STEP_TYPE_TABULAR,
            'limitRows' => 4,
        ],
    ]
]);

When in edit mode it will not populate more than 4 rows from the model. If you wont specify the limitRows option, you can add as many as you want and they will be loaded in edit mode vice versa.

Clone this wiki locally