I got authentication error with right email/pass of registered user when i added new element in login form in ZfcUser.
I added new element in bootstrap function with this lines:
<?php
namespace SystemUser;
use Zend\Mvc\ModuleRouteListener;
use Zend\Mvc\MvcEvent;
public function onBootstrap($e)
{
$events = $e->getApplication()->getEventManager()->getSharedManager();
$sharedEvents->attach('ZfcUser\Form\Login',
'init',
function($e)
{
// @var $form \ZfcUser\Form\Login
$form = $e->getTarget();
// Configure email input
$form->get('identity')
->setAttribute('placeholder', 'Your email')
->setAttribute('class', 'text-input')
->setAttribute('title', 'Your email');
// Configure password input
$form->get('credential')
->setAttribute('placeholder', 'Your password')
->setAttribute('class', 'text-input')
->setAttribute('title', 'Your password');
// Configure submit button
$form->get('submit')
->setAttribute('class', 'btn btn-primary submit');
// Add field "Keep me signed in."
$form->add(
array(
'type' => 'Zend\Form\Element\Checkbox',
'name' => 'keep_signed_in',
'options' => array(
'label' => 'Keep me signed in.',
'use_hidden_Element' => true,
'checked_value' => '1',
'unchecked_value' => '0'
),
'attributes' => array(
'id' => 'keep_signed_in',
),
)
);
}
);
}
But with new element 'keep_signed_in' login form allways returns error "Authentication failed. Please try again."
Please help. What I must to do for dropping this error with real auth params?
Thank you, guys!
I find out solution! :)
I forgot specify filter for this checkbox with required=false:
$sharedEvents->attach('ZfcUser\Form\LoginFilter', 'init', function($e) {
// @var $form \ZfcUser\Form\LoginFilter
$filter = $e->getTarget();
// Custom field keep_signed_in
$filter->add(array(
'name' => 'keep_signed_in',
'required' => false,
)
);
}
);