$validation = \Config\Services::validation();
$request = \Config\Services::request();
$rules = [
'hardware' => [
'label' => 'Hardware',
'rules' => 'required',
'errors' => [
'required' => 'Choose hardware',
],
],
];
// type of hardware if phone, require type of phone
if ($request->getPost('hardware[0]')) {
$rules = [
'phone_type' => [
'label' => 'Phone type',
'rules' => 'required',
'errors' => [
'required' => 'Choose type of phone',
],
],
];
}
if (! $this->validate( $rules )) {
return view('form', [
'validation' => $this->validator
]);
}