Skip to content

Commit 96ac869

Browse files
authored
Merge pull request #5280 from Laravel-Backpack/make-sure-no-white-spaces-on-crud-comma-separated-values
Fix comma separated field names breaking when a space was added
2 parents e57544c + f65c28d commit 96ac869

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/app/Library/CrudPanel/Traits/ColumnsProtectedMethods.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,15 @@ protected function makeSureColumnHasPriority($column)
4747
protected function makeSureColumnHasName($column)
4848
{
4949
if (is_string($column)) {
50-
$column = ['name' => $column];
50+
return ['name' => Str::replace(' ', '', $column)];
5151
}
5252

5353
if (is_array($column) && ! isset($column['name'])) {
5454
$column['name'] = 'anonymous_column_'.Str::random(5);
5555
}
5656

57+
$column['name'] = Str::replace(' ', '', $column['name']);
58+
5759
return $column;
5860
}
5961

src/app/Library/CrudPanel/Traits/FieldsProtectedMethods.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ protected function makeSureFieldHasName($field)
112112
}
113113

114114
if (is_string($field)) {
115-
return ['name' => $field];
115+
return ['name' => Str::replace(' ', '', $field)];
116116
}
117117

118118
if (is_array($field) && ! isset($field['name'])) {
119119
abort(500, 'All fields must have their name defined');
120120
}
121121

122+
$field['name'] = Str::replace(' ', '', $field['name']);
123+
122124
return $field;
123125
}
124126

@@ -272,6 +274,8 @@ protected function makeSureSubfieldsHaveNecessaryAttributes($field)
272274
$subfield = ['name' => $subfield];
273275
}
274276

277+
$subfield['name'] = Str::replace(' ', '', $subfield['name']);
278+
275279
$subfield['parentFieldName'] = $field['name'];
276280

277281
if (! isset($field['model'])) {

0 commit comments

Comments
 (0)