Welcome Guest, Not a member yet? Register   Sign In
Form does not return validation messages using CodeIgniter
#1

(This post was last modified: 11-10-2022, 04:48 AM by SohamMaoor.)

In my HunterModel.php file all the validations and custom messages are from the validations, but I don't know if my form_create.php doesn't show the error messages, they simply return to the form without shows the failures committed by the user, why is this happening?

form_create.php

    <?php if (isset($validation)) : ?>
      <div class="text-danger">
        <?= $validation->listErrors() ?>
      </div>
    <?php endif; ?>
    <form action="<?= site_url('create')?>" method="POST">
                ...
    </form>

In my HunterController.php method createHunter() must do the record insertion operation, checking if everything is right or returns to the form showing the omegle.2yu.co necessary corrections omeglz echat to the user.

HunterController.php

    public function createHunter()
    {
        try {
            helper(['form']);
            $hunter = new HunterModel();
            $data = [
                'name_hunter' => $this->request->getPost('name_hunter'),
                'age_hunter' => $this->request->getPost('age_hunter'),
                'height_hunter' => $this->request->getPost('height_hunter'),
                'weight_hunter' => $this->request->getPost('weight_hunter'),
                'type_hunter' => $this->request->getPost('type_hunter'),
                'type_nen' => $this->request->getPost('type_nen'),
                'type_blood' => $this->request->getPost('type_blood')
            ];
            if ($hunter->insert($data)){
                return $this->response->redirect(site_url('listing'));     
            } else {
                $data['validation'] = $this->validator;
                echo view('form_create', $data);
            }   
        } catch (\Exception $e) {
            exit($e->getMessage());
        }
    }
Reply




Theme © iAndrew 2016 - Forum software by © MyBB