我确实有3个选择。.
<select name="roles" id="roles" class="form-control" ng-model="newUserFormData.roles" multiple required>
<option ng-repeat="role in roleList" value="<% role.id %>"><% role.name %></option>
</select>
<select name="sites" id="sites" class="form-control" ng-model="newUserFormData.sites" multiple>
<option ng-repeat="site in siteList" value="<% site.id %>"><% site.name %></option>
</select>
<select name="projects" id="projects" class="form-control" ng-model="newUserFormData.projects" multiple>
<option ng-repeat="project in projectList" value="<% project.id %>"><% project.name %></option>
</select>
注意:
- 角色可以是多个..是前端必需的..
- (1)-管理员(未包括在选项中)
- (2)-线索
- (3)-分析师
- (4)-密钥输入
- 站点可以是多个..不需要前端..
- (1)-位置1
- (2)-位置2
- (3)-位置3
- 项目可以是多个..不需要前端..
- (1)-项目1
- (2)-项目2
- (3)-项目3
现在是我的验证器..
protected function validatorName(array $data)
{
return Validator::make($data, [
'roles' => 'required|array|min:1',
'sites' => 'required_unless:roles.*,in:2|required_unless:roles.*,in:3',
'projects' => 'required_unless:roles.*,in:2|required_unless:roles.*,in:3',
],[
'sites.required_unless' => 'Site is required unless Lead or Analyst is selected as role.',
'projects.required_unless' => 'Project is required unless Lead or Analyst is selected as role.',
]);
}
问题:
当我选择一个Lead / Analyst作为角色时,它仍然需要站点和项目,而原本不应该的。
请求有效载荷: 角色:[“ 3”],
当我选择“键输入”作为角色时,即使有值,它仍然需要站点和项目。
请求有效载荷: 项目:[“ 1”],角色:[“ 4”],地点:[“ 2”],
我想念什么?