Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[5.x] Allow form fields view to be rendered with single tag #11293

Merged
merged 4 commits into from
Dec 20, 2024
Merged

Conversation

jasonvarga
Copy link
Member

Currently in a form:create tag pair, you can loop over the fields to output predefined html for each field. However, you still have to add the label, instructions, errors, etc.

This PR allows you to use the fields var as a single tag and it will output an entire view for you.

-{{ fields }}
-  <div>
-    <label>{{ display }}</label>
-    {{ field }}
-  </div>
-{{ /fields }}
+{{ fields /}}

The view has basic tailwind based markup, just like the individual fields already do. You may override this view in the same way too by adding resources/views/vendor/statamic/forms/fields.antlers.html.

The view was already in the codebase but never used. Maybe the intention was to do exactly this but it never happened. This PR also tweaks the view a little sto improve padding and to honor configured instruction placement.

@jasonvarga jasonvarga changed the title [5.x] Allow form fields view to be rendered [5.x] Allow form fields view to be rendered with single tag Dec 20, 2024
@jasonvarga jasonvarga merged commit cfbe9d8 into 5.x Dec 20, 2024
19 checks passed
@jasonvarga jasonvarga deleted the fields-loop branch December 20, 2024 17:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant