Anahkiasen / polyglot

Laravel localization and translation helper
130 stars 22 forks source link

__isset magic method doesn't check for main table #5

Closed sidneywidmer closed 10 years ago

sidneywidmer commented 11 years ago

I ran in an issue where form fields created with the form builder didn't pre-populate correctly.

After some debugging I found out that polyglot does only check the _lang table if there are any translated attributes. Because e.g. checkbox values don't need translations, they shouldn't bee stored in the _lang table, but instead stay in the 'normal' table.

My pull request fixes this issue. Polyglot now checks if there's a translated version of this attribute first and if not, just delegates to the parent __isset method. Like that we achieve the desired behavior.

Anahkiasen commented 11 years ago

Can you add a quick test for this ?

sidneywidmer commented 11 years ago

should I refine the test or is it ok like that? Wasn't really sure how to properly mock the model...

Anahkiasen commented 11 years ago

No it's perfect, can you just add braces around your ìf` condition to match the CS in use ?

sidneywidmer commented 11 years ago

would be cool if you could merge that so I can switch from my fork to the official version in my composer.json :)