Closed nbartokos closed 2 years ago
Hmm, you should cast the contact_email
to array using the cast functionality in this package. Then when accessing the value, you should access the corresponding locale key.
So basically, you would have:
NovaSettings::addSettingsFields([
Text::make('Contact email', 'contact_email'),
], ['contact_email' => 'array'], 'Common');
// ...
$email = nova_get_setting('contact_email')[$locale];
That's the easiest way to handle it right now.
Hey,
I noticed that my translated fields are shown correct on the nova-settings page, but the fields on my homepage are shown as json string.
On my homepage I use:
{!! nova_get_setting('contact_email') !!}
Output:
{"en":"email@gmail.com","de":"email@gmail.at"}
On nova-settings:
I used the "HasTranslations" class in my own Settings-Model:
I changed the _nova_getsetting function in the helpers.php File as following:
After this "small" change, everything works perfect now. So did I do something wrong or is this a bug? I works for me now, but I want to know, If I messed something up or found a bug.