Skip to content

Commit

Permalink
FIX Remove non-alphanumeric characters from the readable field name
Browse files Browse the repository at this point in the history
  • Loading branch information
robbieaverill committed Dec 13, 2018
1 parent b56d673 commit a885b5d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/Service/ResourceFieldPopulator.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ protected function parseName($id)
// Swap out certain characters with spaces
$name = str_replace(['_', '-'], ' ', $name);

// Remove non-alphanumeric characters
$name = trim(preg_replace('/[^\w\s]/', '', $name));

return ucfirst($name);
}

Expand Down
2 changes: 1 addition & 1 deletion tests/Service/ResourceFieldPopulatorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function testPopulate()
'type' => 'text',
],
[
'id' => 'field_bar-captain',
'id' => 'field_bar-^captain',
'type' => 'select',
]
]);
Expand Down

0 comments on commit a885b5d

Please sign in to comment.