Skip to content

Commit

Permalink
Merge pull request #5690 from krjohnston/subfield-error-true-fieldname
Browse files Browse the repository at this point in the history
Show the correct tab for subfield errors
  • Loading branch information
pxpm authored Oct 14, 2024
2 parents 9ed23aa + 50c2f11 commit 8a06a85
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/resources/views/crud/inc/show_tabbed_fields.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
}
foreach(session()->get('errors')->getBags() as $bag => $errorMessages) {
foreach($errorMessages->getMessages() as $fieldName => $messages) {
// extract the "parent" field name by separating the field name string by `.digit.` (eg. relation.0.fieldName)
// and take the first element, AKA the "parent" name. In the above example: `relation`
$fieldName = preg_split('/\.\d+\./',$fieldName)[0];
if(array_key_exists($fieldName, $crud->getCurrentFields()) && array_key_exists('tab', $crud->getCurrentFields()[$fieldName])) {
return $crud->getCurrentFields()[$fieldName]['tab'];
}
Expand Down

0 comments on commit 8a06a85

Please sign in to comment.