form
form copied to clipboard
Bind translated name groups
I use dimsav/laravel-translatable with adamwathan/form. In this part of code BootForm::bind($model) does not work:
{!! BootForm::open()->action( route('catalogs.update', $catalog) )->put() !!}
{!! BootForm::bind($catalog) !!}
@foreach($locales AS $locale => $localeData)
{!! BootForm::text('Title', $locale.'[title]') !!}
@endforeach
{!! BootForm::close() !!}
I found only one solution but it is not pretty good:
{!! BootForm::text('Title', $locale.'[title]')->value(isset($catalog->translate($locale)->title)?$catalog->translate($locale)->title:'') !!}
Any ideas why bind don't work on this?
Rather than binding the actual model, you could bind an array of translated attributes. I'm not familiar with dimsav/laravel-translatable, but is something like this possible?
BootForm::bind($catalog->translate($locale)->getAttributes())
If not, you might need to map your own array of translated attributes, and send that mapping to your view. Or inject a view service to do that work right from the view. Nawmean?