Closed emarref closed 7 years ago
I looked into this -- thanks for the gist, which made reproducing this so much easier.
Due to the way Laravel @yield
and @section
work, in your example the Former calls are executed in this unintuitive order:
{!! Former::vertical_open()->id('milkTrackerSetup') !!}
{!! Former::number('field2')->blockhelp('This is the help for field2.') !!}
{!! Former::close() !!}
{!! Former::number('field1')->blockhelp('This is the help for field1.') !!}
As you can see, the Former::number('field1')
call is happening outside of the open()
and close()
calls, which is not currently supported by Former. Former is very stateful in its design, so fields created outside of Former::open()
and Former:close()
have undefined behavior.
As a workaround, consider using @include
instead of @yield
as per this fork of your gist:
https://gist.github.com/claar/3aacc115a8375bc2b7167088535c9809
OK, thanks for looking into it, and also for providing the workaround.
In a Laravel 5.3 project, when a field has a help block set (with bootstrap 3 renderer), the help block is not rendered if the call to open the form is not within the same view file.
E.g. I am rendering test1.blade.php. This view extends test2.blade.php. The test2 view opens and renders a form, and
@yield()
s a section. The test1 view uses@section
to populate this area, and contains a field with a help block.Given the below gist:
https://gist.github.com/emarref/247ed16e7c3b1601fe03fadc09d025dd
Field 2 renders its help block, but field 1 doesn't. I'd expect both help blocks to render.