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

PR #11293 causes documented blade solution for forms to not work. #11369

Open
tom-oneshotdigital opened this issue Jan 17, 2025 · 0 comments
Open

Comments

@tom-oneshotdigital
Copy link

Bug description

After upgrading to version 1.54.0 which included pull request 11293([5.x] Allow form fields view to be rendered with single tag) all of my forms stopped being able to render.

In my case I have followed the Blade version of the documentation from "The Template" which states you have to @foreach over the fields. However the change in this PR changes the result from an array of the form inputs to the FieldsVariable object.

My fix from the documented

// Loop through and render the form inputs
@foreach ($fields as $field)
  <div class="p-2">
    <label>{{ $field['display'] }}</label>
    <div class="p-1">{!! $field['field'] !!}</div>
    @if ($field['error'])
      <p class="text-gray-500">{{ $field['error'] }}</p>
    @endif
  </div>
@endforeach

was to call toArray() on the $fields object

// Loop through and render the form inputs
@foreach ($fields->toArray() as $field)
  <div class="p-2">
    <label>{{ $field['display'] }}</label>
    <div class="p-1">{!! $field['field'] !!}</div>
    @if ($field['error'])
      <p class="text-gray-500">{{ $field['error'] }}</p>
    @endif
  </div>
@endforeach

I feel like $fields->toArray() should just be a workaround as the documented version makes more sense from a Blade point of view.

How to reproduce

Create a form in the control panel, follow the documented solution to render the form using blade templates, $fields are not rendered because they are no longer an array.

Logs

Environment

Environment
Laravel Version: 11.38.2
PHP Version: 8.3.8
Composer Version: 2.5.1
Environment: local
Debug Mode: ENABLED
Maintenance Mode: OFF
Timezone: UTC
Locale: en

Cache
Config: NOT CACHED
Events: CACHED
Routes: CACHED
Views: CACHED

Drivers
Broadcasting: log
Cache: file
Database: mysql
Logs: stack / single
Mail: log
Queue: sync
Session: file

Livewire
Livewire: v3.5.18

Statamic
Addons: 7
Sites: 1
Stache Watcher: Enabled
Static Caching: Disabled
Version: 5.45.1 PRO

Statamic Addons
aerni/font-awesome: 3.0.2
alt-design/alt-cookies: 1.1.7
alt-design/alt-seo: 1.2.2
alt-design/alt-sitemap: 1.2.3
daun/statamic-widget-collection-count: 1.3.1
jonassiewertsen/statamic-livewire: 3.8.1
statamic-rad-pack/mailchimp: 5.2.2

Installation

Fresh statamic/statamic site via CLI

Additional details

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants