Skip to content
This repository has been archived by the owner on Feb 26, 2018. It is now read-only.

Bind translated name groups #116

Open
elephantux opened this issue Feb 7, 2017 · 1 comment
Open

Bind translated name groups #116

elephantux opened this issue Feb 7, 2017 · 1 comment

Comments

@elephantux
Copy link

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?

@jesseleite
Copy link
Contributor

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?

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

No branches or pull requests

2 participants