Welcome Guest, Not a member yet? Register   Sign In
Form validation - Always false?
#1

I have a very basic form with a controller that looks like this:
class Home extends BaseController
PHP Code:
{
    public function index()
    {
        helper(['form''url']);
        if (!$this->validate([

            'naam' => 'required'
        
        
])) {        
            
echo view('form', [
                'validation' => $this->validator,
            ]);
        } else {
            echo "success!";
        }
    }


The view has a section at the top for showing the errors:
PHP Code:
<?php if($validation->listErrors()) {?>
  <div class="alert alert-info" role="alert">
Please check the marked fields
</div>
<?php ?>
</div> 

For some reason the validation is always triggered and I can't figure out why. Should you use seperate functions in CI4?
Reply


Messages In This Thread
Form validation - Always false? - by vinyl - 07-25-2022, 05:21 AM
RE: Form validation - Always false? - by kenjis - 07-26-2022, 05:40 AM
RE: Form validation - Always false? - by demyr - 07-25-2022, 11:32 AM
RE: Form validation - Always false? - by vinyl - 07-25-2022, 10:05 PM
RE: Form validation - Always false? - by demyr - 07-26-2022, 03:43 AM
RE: Form validation - Always false? - by kenjis - 07-26-2022, 06:22 PM
RE: Form validation - Always false? - by kenjis - 07-26-2022, 11:20 PM



Theme © iAndrew 2016 - Forum software by © MyBB