i have a login form and the validator message comes always in pt_BR

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

i have a login form and the validator message comes always in pt_BR

dinispt

this its the zf2 version
*Zend Framework 2.3.0*


i have the Translator set to en_US

the problem its that the message when i press login button without filling the email
always comes in portuguese
"Por favor preencha este campo"

i have searched the entire project for this pt line and i cannot find it
its not inside ZEND_Validate, the pt_BR.po  

the firefox its in portuguese , its this message coming from the browser ?

when remove "required"  keyword it works no validate message its showed


this its the bootstrap on the Auth Module

   public function onBootstrap(MvcEvent $e) {

        $eventManager = $e->getApplication()->getEventManager();
        $moduleRouteListener = new ModuleRouteListener();
        $moduleRouteListener->attach($eventManager);

        $sharedEventManager = $eventManager->getSharedManager(); // The shared event manager

        $sharedEventManager->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH, function($e) {
            $controller = $e->getTarget(); // The controller which is dispatched
            $controllerName = $controller->getEvent()->getRouteMatch()->getParam('controller');

            if (!in_array($controllerName, array('Auth\Controller\Index',
                        'Auth\Controller\Register',
                        'Auth\Controller\Login',
                        'Auth\Controller\UserManager'))) {
               
            }
        });

        $translator = new Translator(new \Zend\I18n\Translator\Translator());
        $translator->addTranslationFile(
                'phpArray', './vendor/zendframework/zendframework/resources/languages/en/Zend_Validate.php'
        );

        $translator->setLocale('en_US');
        AbstractValidator::setDefaultTranslator(new Translator($translator));
    }

this its the login form

<?php
// filename : module/Users/src/Users/Form/RegisterForm.php
namespace Auth\Form;

use Zend\Form\Form;

class LoginForm extends Form
{
    public function __construct($name = null)
    {
        parent::__construct('Login');
        $this->setAttribute('method', 'post');
        $this->setAttribute('enctype','multipart/form-data');

       
        $this->add(array(
            'name' => 'email',
            'attributes' => array(
                'type'  => 'email',
                'required' => 'required',
         
            ),
            'options' => array(
                'label' => 'Email',
             
            ),
        ));
       
       

       
        $this->add(array(
            'name' => 'password',
            'attributes' => array(
                'type'  => 'password',
                'required' => 'required'                
            ),
            'options' => array(
                'label' => 'Password',
            ),
        ));


        $this->add(array(
            'name' => 'submit',
            'attributes' => array(
                //'class' => 'ui-button',
                'type'  => 'submit',
                'value' => 'Login'
            ),
        ));
    }
}

this its the login filter

<?php
namespace Auth\Form;

use Zend\InputFilter\InputFilter;

class LoginFilter extends InputFilter
{
    public function __construct()
    {
        $this->add(array(
            'name'       => 'email',
            'required'   => true,
            'validators' => array(
                array(
                    'name'    => 'EmailAddress',
                    'options' => array(
                        'domain' => true,
                    ),
                ),
            ),
        ));
        $this->add(array(
            'name'       => 'password',
            'required'   => true,
        ));
    }
}
Reply | Threaded
Open this post in threaded view
|

Re: i have a login form and the validator message comes always in pt_BR

David Muir-2
On 08/06/2014, at 4:08 AM, dinispt <[hidden email]> wrote:

>
> this its the zf2 version
> *Zend Framework 2.3.0*
>
>
> i have the Translator set to en_US
>
> the problem its that the message when i press login button without filling
> the email
> always comes in portuguese
> "Por favor preencha este campo"
>
> i have searched the entire project for this pt line and i cannot find it
> its not inside ZEND_Validate, the pt_BR.po  
>
> the firefox its in portuguese , its this message coming from the browser ?
>
> when remove "required"  keyword it works no validate message its showed
>
>
> this its the bootstrap on the Auth Module
>
>   public function onBootstrap(MvcEvent $e) {
>
>        $eventManager = $e->getApplication()->getEventManager();
>        $moduleRouteListener = new ModuleRouteListener();
>        $moduleRouteListener->attach($eventManager);
>
>        $sharedEventManager = $eventManager->getSharedManager(); // The
> shared event manager
>
>        $sharedEventManager->attach(__NAMESPACE__, MvcEvent::EVENT_DISPATCH,
> function($e) {
>            $controller = $e->getTarget(); // The controller which is
> dispatched
>            $controllerName =
> $controller->getEvent()->getRouteMatch()->getParam('controller');
>
>            if (!in_array($controllerName, array('Auth\Controller\Index',
>                        'Auth\Controller\Register',
>                        'Auth\Controller\Login',
>                        'Auth\Controller\UserManager'))) {
>
>            }
>        });
>
>        $translator = new Translator(new
> \Zend\I18n\Translator\Translator());
>        $translator->addTranslationFile(
>                'phpArray',
> './vendor/zendframework/zendframework/resources/languages/en/Zend_Validate.php'
>        );
>
>        $translator->setLocale('en_US');
>        AbstractValidator::setDefaultTranslator(new
> Translator($translator));
>    }
>
> this its the login form
>
> <?php
> // filename : module/Users/src/Users/Form/RegisterForm.php
> namespace Auth\Form;
>
> use Zend\Form\Form;
>
> class LoginForm extends Form
> {
>    public function __construct($name = null)
>    {
>        parent::__construct('Login');
>        $this->setAttribute('method', 'post');
>        $this->setAttribute('enctype','multipart/form-data');
>
>
>        $this->add(array(
>            'name' => 'email',
>            'attributes' => array(
>                'type'  => 'email',
>            'required' => 'required',
>
>            ),
>            'options' => array(
>                'label' => 'Email',
>
>            ),
>        ));
>
>
>
>
>    $this->add(array(
>            'name' => 'password',
>            'attributes' => array(
>                'type'  => 'password',
>            'required' => 'required'                
>            ),
>            'options' => array(
>                'label' => 'Password',
>            ),
>        ));
>
>
>        $this->add(array(
>            'name' => 'submit',
>            'attributes' => array(
>                //'class' => 'ui-button',
>                'type'  => 'submit',
>                'value' => 'Login'
>            ),
>        ));
>    }
> }
>
> this its the login filter
>
> <?php
> namespace Auth\Form;
>
> use Zend\InputFilter\InputFilter;
>
> class LoginFilter extends InputFilter
> {
>    public function __construct()
>    {
>        $this->add(array(
>            'name'       => 'email',
>            'required'   => true,
>            'validators' => array(
>                array(
>                    'name'    => 'EmailAddress',
>                    'options' => array(
>                        'domain' => true,
>                    ),
>                ),
>            ),
>        ));
>        $this->add(array(
>            'name'       => 'password',
>            'required'   => true,
>        ));
>    }
> }
>
>
>
>
> --
> View this message in context: http://zend-framework-community.634137.n4.nabble.com/i-have-a-login-form-and-the-validator-message-comes-always-in-pt-BR-tp4662127.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>
> --
> List: [hidden email]
> Info: http://framework.zend.com/archives
> Unsubscribe: [hidden email]
>
>

The message you are seeing is coming from Firefox.
The required attribute will trigger the browser's form validation. See:
 https://developers.google.com/web/fundamentals/input/form-input/provide-real-time-validation

Cheers,
David