I have the following issue that I cannot solve and also cannot find any solution in this forum (yet)
On my page there is an input form with username + group
Both fields are select-lists that I create using CActiveForm dropDownList() method
The group list has an Item called "add new", when this item is selected a new input is displayed (created with CHtml::textField())
This new textField that is displayed to enter a new group-name is not in database
The desired logic is, that I can add validation to my CActiveRecord to validate that group_id is greater than 0 OR group_name is string longer than 3 characters.
In my database table there are only the two fields user_id and group_id. group_name is not in the table which is linked to CActiveRecord
What I do is, that onBeforeSave I check: If the group_id is 0 and group_name has a value then
Add the group (using a different model)
Read the new group_id and use it
The MAIN problem now is, that there never is an attribute for group_name created in my model.
I cannot validate or process that value.
Possibly there is a way to tell the model, that an attribute can be validated without requiring an database-field
(something like capcha can be validated even though it is not in the database, but I cannot figure out how!)
Thanks for your help