form icon indicating copy to clipboard operation
form copied to clipboard

Bind translated name groups

Open elephantux opened this issue 9 years ago • 1 comments

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?

elephantux avatar Feb 07 '17 23:02 elephantux

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?

jesseleite avatar Feb 08 '17 14:02 jesseleite