/** * Gets the error(s) of a field currently stored in the FormBuilder-object. * Furthermore: If it is the first element of an array (e.g. domainName[0]), * the errors of the array itself are also returned. * This even works for multidimensional arrays. * Example: * This server-side request array: * domainList => [ * 0 => [ * domainLabel => 'first-domain', * domainPdo => 'at', * ], * 1 => [ * domainLabel => 'second-domain', * domainPdo => 'at', * ], * * Returns errors in the following structure: * * - Field 'domainList[0][domainLabel]' returns errors for: * - domainList[0][domainLabel] * - domainList[0] * - domainList * - Field 'domainList[0][domainPdo]' returns errors for: * - domainList[0][domainPdo] * - Field 'domainList[1][domainLabel]' returns errors for: * - domainList[1][domainLabel] * - domainList[1] * - Field 'domainList[1][domainPdo]' returns errors for: * - domainList[1][domainPdo] * * @param string $name * @return array */ public function getErrorsForField($name = '') { $errors = []; if (count($this->errors) > 0) { $errors = FormBuilderTools::extractErrorsForField(FormBuilderTools::convertArrayFieldHtmlName2DotNotation($name), $this->errors, Request::old()); } return $errors; }