Hi, I try to create a scenario to specific searchform; I defined the required attributes inside custom scenario, but when form validate submit, employee_id attribute show required. Employee_id its required in default scenario but I not set it in my custom scenario.
Atrribute: employee_id
[b]Common Model Rules:
[/b]
public function rules()
{
return [
[['rate_id', 'type', 'is_promo', 'employee_id', 'country_group_id'], 'required'],
...
[b]App Model Rules:
[/b]
public function rules()
{
return array_merge(parent::rules(), [
[['last_name', 'rental_confirmation_code','pickup_date', 'dropoff_date'], 'required', 'on' => self::SEARCH_RESERVATION],
[['employee_id','gsa'], 'safe', 'on' => self::SEARCH_RESERVATION],
...
[b]I set scenario:
[/b]
$model = new Reservation(['scenario' => Reservation::SEARCH_RESERVATION]);
View form:
<?= $form->field($model, 'employee_id')->dropDownList(ArrayHelper::map(\common\models\User::find()->where(['agency_id'=>$user->agency_id])->all(), 'id', 'username'),
['class' => 'form-control', 'prompt'=>'- Choose a User -']
)->label(false) ?>
But view validate my the employee_id required (image included).
Its a Yii2 bug or I have any error?