From dad4c8e969b77d0e9b0ce18544944712fbe71c00 Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 6 Feb 2025 18:21:22 -0500 Subject: [PATCH 01/10] Make code snippet indentation more consistent. --- content/collections/tags/form-create.md | 163 +++++++++++------------- 1 file changed, 74 insertions(+), 89 deletions(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index 92c4e946c..45b72ee49 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -26,7 +26,7 @@ parameters: - name: csrf type: boolean - description: When `false`, the hidden `name="_token"` attribute won't be added to the form so you can use other ways of providing the token. Defaults to `true`. + description: When `false`, the hidden `name="_token"` attribute won't be added to the form so you can use other ways of providing the token. Defaults to `true`. - name: files type: boolean @@ -106,30 +106,30 @@ Here we'll be creating a form to submit an entry in a `contact` form. ``` ::tab blade ```blade - - @if (count($errors) > 0) -
- @foreach ($errors as $error) - {{ $error }}
- @endforeach -
- @endif + - @if ($success) -
- {{ $success }} -
- @endif + @if (count($errors) > 0) +
+ @foreach ($errors as $error) + {{ $error }}
+ @endforeach +
+ @endif + + @if ($success) +
+ {{ $success }} +
+ @endif + + + - - + + - - + -
``` :: @@ -147,7 +147,7 @@ You can also use the shorthand syntax for `form:create in="contact"`. ::tab blade ```blade - ... + ... ``` :: @@ -173,16 +173,14 @@ When you need to render a form that's selected via the [Form Fieldtype](/fieldty ::tab antlers ```antlers -{{ form:create in="{ form_fieldtype:handle }" }} +{{ form:create :in="form_fieldtype:handle" }} ... {{ /form:create }} ``` ::tab blade ```blade - - ... + + ... ``` :: @@ -222,22 +220,22 @@ Instead of hardcoding individual fields, you may loop through the `fields` array ```blade - @foreach ($fields as $field) -
- -
{!! $field['field'] !!}
- @if ($field['error']) -

{{ $field['error'] }}

- @endif -
- @endforeach + @foreach ($fields as $field) +
+ +
{!! $field['field'] !!}
+ @if ($field['error']) +

{{ $field['error'] }}

+ @endif +
+ @endforeach - +
``` @@ -286,10 +284,10 @@ This approach, combined with the [blueprint editor](/blueprints), will give you ::tab blade ```blade @foreach ($fields as $field) -
- - {!! $field['field'] !!} -
+
+ + {!! $field['field'] !!} +
@endforeach ``` :: @@ -329,24 +327,23 @@ If you have defined multiple sections in your form's blueprint, you can loop ove {{ /sections }} - + {{ /form:contact }} ``` ::tab blade ```blade - @foreach($sections as $section) -
- {{ $section['display'] }} - - @foreach ($section['fields'] as $field) - ... - @endforeach -
- @endforeach + @foreach($sections as $section) +
+ {{ $section['display'] }} + @foreach ($section['fields'] as $field) + ... + @endforeach +
+ @endforeach - +
``` @@ -392,10 +389,8 @@ The next step is to enable the Alpine JS driver via the `js="alpine"` parameter. ``` ::tab blade ```blade - - ... + + ... ``` :: @@ -420,10 +415,10 @@ Finally, you will need to wire up the fields. With Alpine, this is done using `x ::tab blade ```blade ``` :: @@ -449,20 +444,14 @@ If you are [dynamically rendering your fields](#dynamic-rendering) using the `fi ``` ::tab blade ```blade - - - @foreach ($fields as $field) +@foreach ($fields as $field) - @endforeach - - +@endforeach ``` :: @@ -482,10 +471,8 @@ If you are using other Alpine components in your form or on your page, the inclu ``` ::tab blade ```blade - - ... + + ... ``` :: @@ -508,10 +495,10 @@ If you are hardcoding your inputs, you will need adjust your `x-model` to follow ::tab blade ```blade ``` :: @@ -618,10 +605,8 @@ You can also pass comma-delimited options into the `js` parameter like so: ``` ::tab blade ```blade - - ... + + ... ``` :: From 052df05c087df9d00486344b5866920c0a84a1db Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 6 Feb 2025 18:22:20 -0500 Subject: [PATCH 02/10] Conditional fields are not new anymore. --- content/collections/tags/form-create.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index 45b72ee49..1fa1f9bd6 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -358,7 +358,7 @@ Each item in the `sections` array contains the following data configurable in th | `fields` | array | An array of [fields](#dynamically-rendering-fields) defined within that section | -## Conditional Fields 🆕 +## Conditional Fields You may conditionally show and hide fields by utilizing the [conditional fields](/conditional-fields#overview) settings in your form's blueprint editor. Once configured, by including the necessary front-end scripts and enabling JavaScript on the `form:create` tag, all of the conditional logic will Just Work™. From dfc19437ab91a6e560cea6427112ce002f2b88da Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 6 Feb 2025 19:26:35 -0500 Subject: [PATCH 03/10] Fix link. --- content/collections/tags/form-create.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index 1fa1f9bd6..da2aa1b44 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -45,7 +45,7 @@ variables: name: fields type: array description: > - An array of available fields for [dynamic rendering](#dynamic-rendering). + An array of available fields for [dynamic rendering](#dynamically-rendering-fields). - name: errors type: array @@ -248,7 +248,7 @@ Each item in the `fields` array contains the following data configurable in the | `handle` | string | System name for the field | | `display` | string | User-friendly field label | | `type` | string | Name of the [fieldtype](/fieldtypes) | -| ` field` | string | [Pre-rendered field HTML](#prerendered-field-html) based on the fieldtype | +| `field` | string | [Pre-rendered field HTML](#prerendered-field-html) based on the fieldtype | | `error` | string | Error message from an unsuccessful submission | | `old` | array | Contains user input from an unsuccessful submission | | `instructions` | string | User-friendly instructions label | From b03d98a995a0e2b21fe3ab22c0457cf3a8ffb23b Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 6 Feb 2025 19:27:22 -0500 Subject: [PATCH 04/10] Document `form:fields` tag (still need dedicated doc page though). --- content/collections/tags/form-create.md | 34 ++++++++++++------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index da2aa1b44..02b6279d1 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -189,7 +189,7 @@ This way you can let Control Panel users select which form should be used on an ### Dynamically Rendering Fields -Instead of hardcoding individual fields, you may loop through the `fields` array to render your blueprint's fields in a dynamic fashion. +Instead of hardcoding individual fields, you may loop through the `fields` array using the [form:fields](/tags/form-fields) tag to render your blueprint's fields in a dynamic fashion. ::tabs @@ -197,7 +197,7 @@ Instead of hardcoding individual fields, you may loop through the `fields` array ```antlers {{ form:contact }} - {{ fields }} + {{ form:fields }}
- {{ /fields }} + {{ /form:fields }} @@ -220,7 +220,7 @@ Instead of hardcoding individual fields, you may loop through the `fields` array ```blade - @foreach ($fields as $field) +
- @endforeach +
@@ -274,21 +274,21 @@ This approach, combined with the [blueprint editor](/blueprints), will give you ::tab antlers ```antlers -{{ fields }} +{{ form:fields }}
{{ field }}
-{{ /fields }} +{{ /form:fields }} ``` ::tab blade ```blade -@foreach ($fields as $field) +
{!! $field['field'] !!}
-@endforeach +
``` :: @@ -320,9 +320,9 @@ If you have defined multiple sections in your form's blueprint, you can loop ove {{ sections }}
{{ display }} - {{ fields }} + {{ form:fields }} ... - {{ /fields }} + {{ /form:fields }}
{{ /sections }} @@ -337,9 +337,9 @@ If you have defined multiple sections in your form's blueprint, you can loop ove @foreach($sections as $section)
{{ $section['display'] }} - @foreach ($section['fields'] as $field) + ... - @endforeach +
@endforeach @@ -433,25 +433,25 @@ If you are [dynamically rendering your fields](#dynamic-rendering) using the `fi ::tab antlers ```antlers -{{ fields }} +{{ form:fields }} -{{ /fields }} +{{ /form:fields }} ``` ::tab blade ```blade -@foreach ($fields as $field) + -@endforeach + ``` :: From 6dd6e7326d748a2f2022e7b1af4f808fe0e1be3f Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Thu, 6 Feb 2025 19:30:30 -0500 Subject: [PATCH 05/10] =?UTF-8?q?You=20don=E2=80=99t=20need=20`{!!=20!!}`?= =?UTF-8?q?=20anymore=20because=20`field`=20is=20`Htmlable`=20=F0=9F=A4=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- content/collections/tags/form-create.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index 02b6279d1..73fa072db 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -228,7 +228,7 @@ Instead of hardcoding individual fields, you may loop through the `fields` array * @endif -
{!! $field['field'] !!}
+
{{ $field['field'] }}
@if ($field['error'])

{{ $field['error'] }}

@endif @@ -286,7 +286,7 @@ This approach, combined with the [blueprint editor](/blueprints), will give you
- {!! $field['field'] !!} + {{ $field['field'] }}
``` @@ -448,7 +448,7 @@ If you are [dynamically rendering your fields](#dynamic-rendering) using the `fi From fda7e18e6a881965c79494e5f7e5392d26efc364 Mon Sep 17 00:00:00 2001 From: Jesse Leite Date: Tue, 11 Mar 2025 19:44:48 -0400 Subject: [PATCH 06/10] Improve top-level `show_field` syntax for nested group field JS. --- content/collections/tags/form-create.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/content/collections/tags/form-create.md b/content/collections/tags/form-create.md index 73fa072db..7ceedcf20 100644 --- a/content/collections/tags/form-create.md +++ b/content/collections/tags/form-create.md @@ -405,7 +405,7 @@ Finally, you will need to wire up the fields. With Alpine, this is done using `x ::tab antlers ```antlers -