Languagebehavior

I had a problem yesterday with this extension:

http://www.yiiframework.com/extension/yii-language-behavior/

It was not working with ajaxvalidation. I have change the

public function afterValidate($event) in LanguageBehavior.php and now it’s working.

Fixed code below




    public function afterValidate($event) {

        $owner = $this->getOwner();

        $owner_class = get_class($owner);


        // grab our posted translation attributes

        foreach ($this->translationColumns as $field) {

            if (isset($_POST[$owner_class][$field]))

                $owner->$field = $_POST[$owner_class][$field];

        }

        // validate translation attributes

        foreach ($this->languages as $val) {

            $translation = new $this->translationClass;

            foreach ($this->translationColumns as $field) {

                $translation->$field = $owner->{$field}[$val['id']];

                if (!$translation->validate(array($field))) {

                    $owner->translation_error[$field][$val['id']] = $translation->getErrors();

                    foreach ($translation->getErrors() as $error) {

                        $owner->addError($field . '_' . ($val['id']), $error);

                    }

                }

            }

        }

        // add errors to model errors for display at top of form

        if ($owner->translation_error) {

            $owner->addErrors($owner->translation_error);

            return false;

        }

        return true;

    }



P.S. I’ve paste it here because I havn’t got enough permission to add Wikipage and to comment the extension.