/** * Validate the form * * @param array $validationRules * @param array $messages * @return Validator */ public function validate($validationRules = [], $messages = []) { $fieldRules = $this->formHelper->mergeFieldsRules($this->fields); $rules = array_merge($fieldRules['rules'], $validationRules); $this->validator = $this->validatorFactory->make($this->getRequest()->all(), $rules, $messages); $this->validator->setAttributeNames($fieldRules['attributes']); return $this->validator; }
/** * Handle a failed validation attempt. * * @param \Illuminate\Contracts\Validation\Validator $validator. * @return mixed */ protected function failedValidation(Validator $validator) { // Set custom error attibute names $validator->setAttributeNames($this->labels); //TODO not working. According to dd($validator) the instance has the right attibute names but they are not used! return parent::failedValidation($validator); }