Skip to content

Commit

Permalink
Merge pull request #5614 from Laravel-Backpack/do-not-error-on-arraye…
Browse files Browse the repository at this point in the history
…d-names

Do not error on arrayed field names
  • Loading branch information
pxpm committed Aug 15, 2024
2 parents 1028782 + 2fc6d18 commit eadbde8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/app/Library/CrudPanel/CrudField.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ public function __construct($nameOrDefinitionArray)
$name = $nameOrDefinitionArray;
}

if (is_array($name)) {
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($name));
}

$field = $this->crud()->firstFieldWhere('name', $name);

// if field exists
Expand Down
4 changes: 4 additions & 0 deletions src/app/Library/CrudPanel/Traits/FieldsProtectedMethods.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ protected function makeSureFieldHasName($field)
abort(500, 'All fields must have their name defined');
}

if (is_array($field['name'])) {
abort(500, 'Field name can\'t be an array. It should be a string. Error in field: '.json_encode($field['name']));
}

$field['name'] = Str::replace(' ', '', $field['name']);

return $field;
Expand Down

0 comments on commit eadbde8

Please sign in to comment.