I have a CFormModel that has attributes that are arrays. I was wondering how I might be able to handle validating these attributes? Validators are pretty strict about having attributes that aren’t arrays. I would like to use one single model, not many models. Is there a way around this WITHOUT using tabular data(multiple models)? And if so, how might I go about doing this?
I thought about using tabular data, but it doesn’t seem like an optimal solution in my case. I am building a more complex search page that has a dynamic number of attributes.
Each of the attrib params will be a set number of attributes within the model, but the number of values within that attribute could be unlimited (perhaps 40 models with 1 attribute, or 1 model with an attribute that is an array with 40 values). The issue is that I need to validate the data and then after validation, I need direct access to all data at one time. For example
Attributes can be arrays. Think about select boxes that allow multiple selection or checkbox lists. This has nothing to do with tabular input. Instead i’d suggest to write your own validator class (or method). See here for an example how to write such a custom validator method: