Passing dynamic value to validation rules in model

Hi! Hope you guys can help me understand this about passing values to validation rules in a model.

My scenario is: A system where users book seminars they want to attend. In the table Seminar there is a column containing information about how one special input-field on the bookingform should be validated before creating a record in the booking table. The validation rule instructions comes from a table column because the seminar administrators can deside the rule behavior when creating a seminar.

In the bookingController in var $seminar I have a ARObject containing a seminar-record. When setting up the validation rules for the posted bookingform input inside the booking model I want to use a value from a column inside the var $seminar set in bookingController.

Depending on the table-value several different validations can be applied, to many different validations to simply set up different validationScenarios for each possible combination. The best solution I can figure out is to pass the field-value from the bookingController to the booking model instance and inside the booking model dynamically generate the set of arrays returned by the method Rules().

To put it in one phrase: I want to create dynamic validation rules in my model, based on values fetched from DB in the controller… phew

So basically three questions:

1: How to pass a value from a controller to a model (i tried a constructor with a param in the model… did not work well)

2: Is there a better way I did not think of yet?

3: I´m confused, does anyone understand the the h*ll i´m talking about?


i have the same question how to pass data to model either way by controllers or by viewwwwwwwwwwwwww…this is the big isssue i.e the accessibility of variables

Perhaps to create a custom validator inline or as a class.

From the guide:

The seminar record could be brought in by the custom validator. The custom validator could be made effective only for a certain scenario.


$model = new BookingForm('some_scenario')


if ($model->validate())