Hi, all!
I have a form with 3 fields and 2 scenarios.
Here’s my model rules:
// DailyReport model
public function rules()
{
return array(
array(
'date',
'required',
'on' => 'reportByDate'
),
array(
'date',
'date',
'format'=>array('yyyy-MM-dd'),
'message' => 'Bad date format. Should be yyyy-mm-dd.',
'on' => 'reportByDate',
),
array(
'startDate, endDate',
'required',
'on' => 'reportByDateRange'
),
array(
'startDate, endDate',
'date',
'format'=>array('yyyy-MM-dd'),
'message' => 'Bad date format. Should be yyyy-mm-dd.',
'on' => 'reportByDateRange',
),
);
}
When I submit form with ‘date’ attribute set and create model like so
$model = new DailyReport('reportByDate');
I get 2 warnings:
Failed to set unsafe attribute "startDate" of "DailyReport"
Failed to set unsafe attribute "endDate" of "DailyReport"
And vice versa, when I submit form with ‘startDate’ and ‘endDate’ attributes set and create model like so
$model = new DailyReport('reportByDateRange');
I get 1 warning:
Failed to set unsafe attribute "date" of "DailyReport"
Now, as far as I understand when a model’s attribute is not assigned a validator or not explicitly marked by ‘safe’ for a particular scenario - it’s not assigned during massive assignment.
But my question is: does it mean that unsafe attributes for current scenario will always produce this warning in log file? I guess there will be too many warnings if this is the way it is.