Mayur Koshti
Mayur Koshti

Reputation: 1852

Form Helper form_open() not working in CodeIgniter 4

It doesn't work....

<?=form_open('userupdate')?> <?=form_close()?>

Getting 404 error.

I tried without short tag also.

The form tag works fine....

<form method="post" action="<?php base_url('userupdate')?>" name="frmUserUpdate">
</form>

While UserAdd form works fine using form_open() method. Please note that I have declared in autoload.php and in BaseController.php.

I spent lot of time but I couldn't figure out where is the problem?

Can anyone look into this?

Controllers:

$routes->get('useredit/(:num)', 'UserControllers\UseraddController::useredit/$1');

$routes->post('useredit/(:num)', 'UserControllers\UseraddController::update/$1');

Upvotes: 0

Views: 96

Answers (1)

DeanE10
DeanE10

Reputation: 188

Make sure the helper is included with your methods or in BaseController

UseraddController.php

    public function useredit()
    {
        helper('form');
        //...
    }


    public function update()
    {
        helper('form');
        //...
    }

BaseController.php

    protected $helpers = [
        //...
        'form',
    ];  

Upvotes: 1

Related Questions