diff --git a/resources/views/extend/forms/fields.antlers.html b/resources/views/extend/forms/fields.antlers.html index 519bc79910..140c41c90a 100644 --- a/resources/views/extend/forms/fields.antlers.html +++ b/resources/views/extend/forms/fields.antlers.html @@ -6,11 +6,8 @@ * {{ /if }} - {{ if instructions && instructions_position == "above" }} -

{{ instructions }}

- {{ /if }} -
{{ field }}
- {{ if instructions && instructions_position == "below" }} +
{{ field }}
+ {{ if instructions }}

{{ instructions }}

{{ /if }} {{ if error }} diff --git a/src/Forms/FieldsVariable.php b/src/Forms/FieldsVariable.php deleted file mode 100644 index 542333370d..0000000000 --- a/src/Forms/FieldsVariable.php +++ /dev/null @@ -1,21 +0,0 @@ - $fields])->render(), - $fields - ); - } - - public function toArray() - { - return $this->extra; - } -} diff --git a/src/Forms/Tags.php b/src/Forms/Tags.php index 8a7d816043..f44018e7c6 100644 --- a/src/Forms/Tags.php +++ b/src/Forms/Tags.php @@ -74,7 +74,7 @@ public function create() $data['sections'] = $this->getSections($this->sessionHandle(), $jsDriver); - $data['fields'] = new FieldsVariable(collect($data['sections'])->flatMap->fields->all()); + $data['fields'] = collect($data['sections'])->flatMap->fields->all(); $data['honeypot'] = $form->honeypot(); diff --git a/tests/Tags/Form/FormCreateTest.php b/tests/Tags/Form/FormCreateTest.php index cbbd668037..3be2cc95ad 100644 --- a/tests/Tags/Form/FormCreateTest.php +++ b/tests/Tags/Form/FormCreateTest.php @@ -5,13 +5,10 @@ use Illuminate\Http\UploadedFile; use Illuminate\Support\Facades\Event; use Illuminate\Support\Facades\Storage; -use Illuminate\Testing\Assert as PHPUnit; -use Illuminate\Testing\Constraints\SeeInOrder; use Illuminate\Validation\ValidationException; use PHPUnit\Framework\Attributes\Test; use Statamic\Facades\AssetContainer; use Statamic\Facades\Form; -use Statamic\Forms\FieldsVariable; use Statamic\Statamic; class FormCreateTest extends FormTestCase @@ -77,26 +74,6 @@ public function it_dynamically_renders_fields_array() $this->assertEquals(['Full Name', 'Email Address', 'Message'], $fieldOrder[1]); } - #[Test] - public function it_dynamically_renders_fields_view_using_single_tag() - { - $output = $this->normalizeHtml($this->tag(<<<'EOT' -{{ form:contact }} - {{ fields }} -{{ /form:contact }} -EOT - )); - - PHPUnit::assertThat([ - '', - '', - '', - '', - '', - '', - ], new SeeInOrder($output)); - } - #[Test] public function it_dynamically_renders_with_form_handle() { @@ -527,20 +504,20 @@ public function it_dynamically_renders_sections_array() $output = $this->normalizeHtml($this->tag(<<<'EOT' {{ form:survey }} {{ sections }} -
{{ if display}}{{ display }} - {{ /if }}{{ if instructions }}{{ instructions }} - {{ /if }}{{ fields }}[{{ handle }}]{{ /fields }}
+
{{ if display}}{{ display }} - {{ /if }}{{ if instructions }}{{ instructions }} - {{ /if }}{{ fields | pluck('handle') | join(',') }}
{{ /sections }} -
{{ fields }}[{{ handle }}]{{ /fields }}
+
{{ fields | pluck('handle') | join(',') }}
{{ /form:survey }} EOT )); - $this->assertStringContainsString('
One - One Instructions - [alpha][bravo]
', $output); - $this->assertStringContainsString('
Two - Two Instructions - [charlie][delta]
', $output); - $this->assertStringContainsString('
[echo][fox]
', $output); + $this->assertStringContainsString('
One - One Instructions - alpha,bravo
', $output); + $this->assertStringContainsString('
Two - Two Instructions - charlie,delta
', $output); + $this->assertStringContainsString('
echo,fox
', $output); // Even though the fields are all nested within sections, // we should still be able to get them via `{{ fields }}` array at top level... - $this->assertStringContainsString('
[alpha][bravo][charlie][delta][echo][fox]
', $output); + $this->assertStringContainsString('
alpha,bravo,charlie,delta,echo,fox
', $output); } #[Test] @@ -858,7 +835,7 @@ public function it_fetches_form_data() $this->assertArrayHasKey('_token', $form['params']); $this->assertIsArray($form['errors']); - $this->assertInstanceOf(FieldsVariable::class, $form['fields']); + $this->assertIsArray($form['fields']); $this->assertEquals($form['honeypot'], 'winnie'); $this->assertEquals($form['js_driver'], 'alpine');