diff --git a/composer.json b/composer.json index 5be747a..1c576a3 100644 --- a/composer.json +++ b/composer.json @@ -11,7 +11,7 @@ ], "require": { "php": ">=5.3.0", - "laravelcollective/html": "5.*", + "laravelcollective/html": "^5.4", "illuminate/support": ">=4.2", "illuminate/validation": ">=4.0", "illuminate/routing": ">=4.0" diff --git a/src/Bllim/Laravalid/Converter/JqueryValidation/Message.php b/src/Bllim/Laravalid/Converter/JqueryValidation/Message.php index 6b8b95b..cd689b7 100644 --- a/src/Bllim/Laravalid/Converter/JqueryValidation/Message.php +++ b/src/Bllim/Laravalid/Converter/JqueryValidation/Message.php @@ -16,7 +16,7 @@ public function ip($parsedRule, $attribute, $type) public function same($parsedRule, $attribute, $type) { - $message = Lang::get('validation.'.$parsedRule['name'], ['attribute' => $attribute]); + $message = Helper::getValidationMessage($attribute, $parsedRule['name'], ['other' => $parsedRule['parameters'][0]]); return ['data-msg-equalto' => $message]; } diff --git a/src/Bllim/Laravalid/FormBuilder.php b/src/Bllim/Laravalid/FormBuilder.php index bdfcdae..47b987a 100644 --- a/src/Bllim/Laravalid/FormBuilder.php +++ b/src/Bllim/Laravalid/FormBuilder.php @@ -27,9 +27,9 @@ class FormBuilder extends \Collective\Html\FormBuilder { protected $converter; - public function __construct(\Collective\Html\HtmlBuilder $html, \Illuminate\Routing\UrlGenerator $url, $csrfToken, Converter\Base\Converter $converter) + public function __construct(\Collective\Html\HtmlBuilder $html, \Illuminate\Routing\UrlGenerator $url, \Illuminate\View\Factory $view, $csrfToken, Converter\Base\Converter $converter) { - parent::__construct($html, $url, $csrfToken); + parent::__construct($html, $url, $view, $csrfToken); $plugin = \Config::get('laravalid.plugin'); $this->converter = $converter; } diff --git a/src/Bllim/Laravalid/Helper.php b/src/Bllim/Laravalid/Helper.php index 1f54bd2..ab7170b 100644 --- a/src/Bllim/Laravalid/Helper.php +++ b/src/Bllim/Laravalid/Helper.php @@ -42,6 +42,11 @@ public static function getValidationMessage($attribute, $rule, $data = [], $type } $niceName = !\Lang::has('validation.attributes.'.$attribute) ? $attribute : \Lang::get('validation.attributes.'.$attribute); + + //reform data so that all fields have nice names + foreach ($data as $key => $fieldName) { + $data[$key] = !\Lang::has('validation.attributes.'.$fieldName) ? $fieldName : \Lang::get('validation.attributes.'.$fieldName); + } return \Lang::get('validation.'.$path, $data + ['attribute' => $niceName]); } diff --git a/src/Bllim/Laravalid/LaravalidServiceProvider.php b/src/Bllim/Laravalid/LaravalidServiceProvider.php index 46c9364..36207e1 100644 --- a/src/Bllim/Laravalid/LaravalidServiceProvider.php +++ b/src/Bllim/Laravalid/LaravalidServiceProvider.php @@ -54,7 +54,7 @@ public function register() $converterClassName = 'Bllim\Laravalid\Converter\\'.$plugin.'\Converter'; $converter = new $converterClassName(); - $form = new FormBuilder($app->make('html'), $app->make('url'), $app->make('session.store')->getToken(), $converter); + $form = new FormBuilder($app->make('html'), $app->make('url'), $app->make('view'), $app->make('session.store')->token(), $converter); return $form->setSessionStore($app->make('session.store')); }