Skip to content
This repository has been archived by the owner on Jun 18, 2019. It is now read-only.

Validation of translated model with Ardent #31

Closed
mdiniz opened this issue Jul 21, 2014 · 5 comments
Closed

Validation of translated model with Ardent #31

mdiniz opened this issue Jul 21, 2014 · 5 comments

Comments

@mdiniz
Copy link

mdiniz commented Jul 21, 2014

Hi there

I just got Translatable working with Ardent with the help of your gist but I'm facing an issue.

To use your example with Country, both Country and CountryTranslation would extend Ardent. I would like to validate the name of the country (say, max 100 characters). For that I would configure the validator in CountryTranslation. I'm able to save translations when the name is valid. So far so good.

If I do something like this:

$country->translate('en')->name = 'a very long name with more than 100 chars';
$country->save();

Then CountryTranslation doesn't save (which is right, since it's not valid). However, I'm unable to get the error messages. If I do $country->errors()->all(), the list of errors is empty. Also, $country->validate() returns true, which is weird.

Do you have any idea about this? That's probably not an issue with Translatable itself, just the way it integrates with Ardent.

@dimsav
Copy link
Owner

dimsav commented Jul 25, 2014

Could anyone using Ardent respond to this?

@RyanThompson
Copy link

I will be happy to as soon as I get it implemented.

@joachimVT
Copy link

I am facing the same problem, is there already any solution ?

When the name is not valid in the translation table, a record is still created in the country table. Shouldn't that be stopped ? When there is an error no record should be created...

@mvdstam
Copy link

mvdstam commented Feb 3, 2015

I've come up with a solution, by simply coming up with a base model that both extends Ardent and uses the Translatable trait: https://github.com/mvdstam/ardent-translatable/.

It's also on Packagist, but use it on your own risk 😃. I've done some preliminary testing and everything seems to play pretty nice with each other. Using this base class also fixes #12.

@dimsav
Copy link
Owner

dimsav commented Feb 4, 2015

👍 @mvdstam I will put this on the readme file as soon as it is stable.

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

No branches or pull requests

6 participants