Login form with bootstrap 2.x convert to 4.x

Below is my cakephp 2.x code, can someone help me to make this work in my current cakephp 4.x project

<?php echo $this->Form->create('User', array('url'=>array('controller'=>'main', 'action'=>'login'), 'class'=>'', 'id'=>'', 'inputDefaults'=>array('label'=>false, 'div'=>false, 'class'=>'form-control' ))) ?>


<?php echo $this->Form->input('username', array('required'=>true, 'placeholder'=>'USERNAME', 'autofocus'=>true, 'class'=>'form-control input-form')) ?>
<?php echo $this->Form->input('password', array('required'=>true, 'placeholder'=>'PASSWORD', 'class'=>'form-control input-form')) ?>
            <button class="btn btn-primary pull-right btn-min">
            	SIGN IN

There is a tutorial in the documentation, that covers the form and the required plugin (in cake 4 “authentication plugin” replaced the “auth plugin”:

1 Like

Then authentication is removing my project name. What is the posible cause for this problem . i followed the instruction base on the URL .

The URL should be . localhost/cms/login.

Please try this:
In your Application.php in function getAuthenticationService…
'unauthenticatedRedirect' => '/login',
'unauthenticatedRedirect' => \Cake\Routing\Router::url('/users/login'),

'loginUrl' => \Cake\Routing\Router::url('/users/login'),

1 Like
  • It works fine now . but i have a query . Can i remove the “redirect=%2F” when access the base URL

honestly said, I don’t know if or how you can remove it.
it simply show the referring page.

1 Like

I see. Anyways thank you for your help really big hellp
I am currently upgrading may Cakephp 2.x to 4.x so its hard for me to understand the structures.
Keep in touch .