Skip to content

Commit

Permalink
Generated pubtype field names should be lower/kebab case
Browse files Browse the repository at this point in the history
Generated PublicationFieldType field names should be lower/kebab case to match the constructor normalization made in the PublicationFieldType class

_Originally posted by @caendesilva in #685 (comment)
  • Loading branch information
caendesilva committed Dec 4, 2022
1 parent 42ce1d6 commit 57fdf70
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ protected function captureFieldsDefinitions(): Collection

$field = Collection::create();
do {
$field->name = trim($this->askWithValidation('name', 'Field name', ['required']));
$field->name = Str::kebab(trim($this->askWithValidation('name', 'Field name', ['required'])));
$duplicate = $fields->where('name', $field->name)->count();
if ($duplicate) {
$this->error("Field name [$field->name] already exists!");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public function test_command_creates_publication_type()
{
$this->artisan('make:publicationType')
->expectsQuestion('Publication type name', 'Test Publication')
->expectsQuestion('Field name', 'Title')
->expectsQuestion('Field name', 'Publication Title')
->expectsQuestion('Field type (1-10)', 1)
->expectsQuestion('Min value (for strings, this refers to string length)', 'default')
->expectsQuestion('Max value (for strings, this refers to string length)', 'default')
Expand All @@ -41,7 +41,7 @@ public function test_command_creates_publication_type()
<<<'JSON'
{
"name": "Test Publication",
"canonicalField": "Title",
"canonicalField": "publication-title",
"sortField": "__createdAt",
"sortDirection": "ASC",
"pageSize": 10,
Expand All @@ -50,7 +50,7 @@ public function test_command_creates_publication_type()
"listTemplate": "test-publication_list",
"fields": [
{
"name": "Title",
"name": "publication-title",
"min": "default",
"max": "default",
"type": "string"
Expand Down

0 comments on commit 57fdf70

Please sign in to comment.