From 73ee71c2047be1df7aff840238d604d9041bbb27 Mon Sep 17 00:00:00 2001 From: Martin Lagler Date: Fri, 19 May 2023 11:41:36 +0200 Subject: [PATCH 1/4] Added hidden field --- Dynamic/Types/HiddenType.php | 46 +++++++++++++++++++ Entity/Dynamic.php | 1 + Resources/config/form-fields/field_hidden.xml | 23 ++++++++++ Resources/config/types.xml | 4 ++ Resources/translations/admin.de.json | 1 + Resources/translations/admin.en.json | 1 + 6 files changed, 76 insertions(+) create mode 100644 Dynamic/Types/HiddenType.php create mode 100644 Resources/config/form-fields/field_hidden.xml diff --git a/Dynamic/Types/HiddenType.php b/Dynamic/Types/HiddenType.php new file mode 100644 index 00000000..7ea821f6 --- /dev/null +++ b/Dynamic/Types/HiddenType.php @@ -0,0 +1,46 @@ +add($field->getKey(), $type, $options); + } +} diff --git a/Entity/Dynamic.php b/Entity/Dynamic.php index 0dbc647c..0927c638 100644 --- a/Entity/Dynamic.php +++ b/Entity/Dynamic.php @@ -32,6 +32,7 @@ class Dynamic implements AuditableInterface 'headline', 'freeText', 'recaptcha', + 'hidden', ]; /** diff --git a/Resources/config/form-fields/field_hidden.xml b/Resources/config/form-fields/field_hidden.xml new file mode 100644 index 00000000..e9424249 --- /dev/null +++ b/Resources/config/form-fields/field_hidden.xml @@ -0,0 +1,23 @@ + + + + + sulu_form.title + + + + + + sulu_form.short_title + sulu_form.short_title_description + + + + + + sulu_form.default + + + diff --git a/Resources/config/types.xml b/Resources/config/types.xml index 28820327..3145937c 100644 --- a/Resources/config/types.xml +++ b/Resources/config/types.xml @@ -111,5 +111,9 @@ + + + + diff --git a/Resources/translations/admin.de.json b/Resources/translations/admin.de.json index 0cca92af..175d4491 100644 --- a/Resources/translations/admin.de.json +++ b/Resources/translations/admin.de.json @@ -67,6 +67,7 @@ "sulu_form.type.radiobuttons": "Radio Buttons", "sulu_form.type.recaptcha": "Captcha", "sulu_form.type.mailchimp": "Mailchimp", + "sulu_form.type.hidden": "Hidden", "sulu_form.width.full": "Voll", "sulu_form.width.half": "Halb", "sulu_form.width.one_quarter": "Ein Viertel", diff --git a/Resources/translations/admin.en.json b/Resources/translations/admin.en.json index 298ce36b..f5941e9d 100644 --- a/Resources/translations/admin.en.json +++ b/Resources/translations/admin.en.json @@ -67,6 +67,7 @@ "sulu_form.type.radiobuttons": "Radio Buttons", "sulu_form.type.recaptcha": "Captcha", "sulu_form.type.mailchimp": "Mailchimp", + "sulu_form.type.hidden": "Hidden", "sulu_form.width.full": "Full", "sulu_form.width.half": "Half", "sulu_form.width.one_quarter": "One quarter", From 052073e07a69070ba108caee83f7bcaf6e487dd1 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Wed, 7 Jun 2023 14:14:31 +0200 Subject: [PATCH 2/4] Update Dynamic/Types/HiddenType.php --- Dynamic/Types/HiddenType.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dynamic/Types/HiddenType.php b/Dynamic/Types/HiddenType.php index 7ea821f6..b8e9cdb0 100644 --- a/Dynamic/Types/HiddenType.php +++ b/Dynamic/Types/HiddenType.php @@ -18,7 +18,7 @@ use Symfony\Component\Form\FormBuilderInterface; /** - * The Email form field type. + * The Hidden form field type. */ class HiddenType implements FormFieldTypeInterface { From 5c9dc6bbe4ef9b4623c45c498200563d49150a74 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Fri, 19 Apr 2024 13:25:09 +0200 Subject: [PATCH 3/4] Update DynamicFormMetadataLoaderTest.php --- .../Metadata/DynamicFormMetadataLoaderTest.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php b/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php index fe05cd1b..b08bac4e 100644 --- a/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php +++ b/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php @@ -48,7 +48,7 @@ public function testGetMetadataEnglish(): void $fields = $formFields->getItems()['fields']; $this->assertInstanceOf(FieldMetadata::class, $fields); - $this->assertCount(27, $fields->getTypes()); + $this->assertCount(28, $fields->getTypes()); $this->assertEquals('fields', $fields->getName()); $this->assertEquals('block', $fields->getType()); $this->assertEquals('attachment', $fields->getDefaultType()); @@ -67,6 +67,7 @@ public function testGetMetadataEnglish(): void 'freeText', 'function', 'headline', + 'hidden', 'lastName', 'textarea', 'phone', @@ -106,7 +107,7 @@ public function testGetMetadataGerman(): void $fields = $formFields->getItems()['fields']; $this->assertInstanceOf(FieldMetadata::class, $fields); - $this->assertCount(27, $fields->getTypes()); + $this->assertCount(28, $fields->getTypes()); $this->assertEquals('fields', $fields->getName()); $this->assertEquals('block', $fields->getType()); $this->assertEquals('attachment', $fields->getDefaultType()); @@ -138,6 +139,7 @@ public function testGetMetadataGerman(): void 'title', 'firstName', 'headline', + 'hidden', ], \array_keys($fields->getTypes())); } @@ -184,7 +186,7 @@ public function testGetMetadataAttachmentEnglish(): void $fields = $formFields->getItems()['fields']; $this->assertInstanceOf(FieldMetadata::class, $fields); - $this->assertCount(27, $fields->getTypes()); + $this->assertCount(28, $fields->getTypes()); $attachment = $fields->getTypes()['attachment']; $this->assertInstanceOf(FormMetadata::class, $attachment); @@ -253,7 +255,7 @@ public function testGetMetadataAttachmentGerman(): void $fields = $formFields->getItems()['fields']; $this->assertInstanceOf(FieldMetadata::class, $fields); - $this->assertCount(27, $fields->getTypes()); + $this->assertCount(28, $fields->getTypes()); $attachment = $fields->getTypes()['attachment']; $this->assertInstanceOf(FormMetadata::class, $attachment); From 36d413ef9e8ccc370f83aa18d4ca8ac09eacbd86 Mon Sep 17 00:00:00 2001 From: Alexander Schranz Date: Fri, 19 Apr 2024 13:32:21 +0200 Subject: [PATCH 4/4] Update DynamicFormMetadataLoaderTest.php --- Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php b/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php index b08bac4e..39f800f2 100644 --- a/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php +++ b/Tests/Functional/Metadata/DynamicFormMetadataLoaderTest.php @@ -127,6 +127,7 @@ public function testGetMetadataGerman(): void 'company', 'freeText', 'function', + 'hidden', 'country', 'spacer', 'textarea', @@ -139,7 +140,6 @@ public function testGetMetadataGerman(): void 'title', 'firstName', 'headline', - 'hidden', ], \array_keys($fields->getTypes())); }