CodeIgniter Forums
Issue with form validation - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Issue with form validation (/showthread.php?tid=71813)

Pages: 1 2


RE: Issue with form validation - happyape - 10-01-2018

(10-01-2018, 01:18 AM)unodepiera Wrote:
(10-01-2018, 12:47 AM)happyape Wrote: Yes that makes sense to me. Thank you.

In the documentation there was no suggestion to check for the POST request so I thought it would do validation for POST requests only.

Your are right, the documentation must be updated with best practices.

If i wanted to add something into documentation so that it helps everyone - how do I do that?


RE: Issue with form validation - dave friend - 10-01-2018

(10-01-2018, 01:55 AM)happyape Wrote:
(10-01-2018, 01:18 AM)unodepiera Wrote:
(10-01-2018, 12:47 AM)happyape Wrote: Yes that makes sense to me. Thank you.

In the documentation there was no suggestion to check for the POST request so I thought it would do validation for POST requests only.

Your are right, the documentation must be updated with best practices.

If i wanted to add something into documentation so that it helps everyone - how do I do that?

It might be easiest to go HERE and create a New Issue.

At this time I don't see any open issues on this topic.


RE: Issue with form validation - InsiteFX - 10-01-2018

@Dave friend I did open an issue and James is taking care of it on GitHub.


RE: Issue with form validation - dave friend - 10-01-2018

(10-01-2018, 10:40 AM)InsiteFX Wrote: @Dave friend I did open an issue and James is taking care of it on GitHub.

Huh. I don't see an open issue on this. I do find a closed issue - Issue #1214 which seems to be related. But I don't find anything in the current develop branch to show where/how it was addressed.

I only bring this up so that this discussion gets the attention it deserves.


RE: Issue with form validation - InsiteFX - 10-01-2018

You can bring it up again, but James said he was going to take care of it.


RE: Issue with form validation - Ekley - 10-11-2019

Hello. Is the related "bug" solved? I am facing the same issue. In the meantime, I'll check the getMethod() of the Request class to ensure that posting occured.


RE: Issue with form validation - Bart Goossens - 08-22-2020

Strange error on if($this->request->getMethod())
Solved it in version 4.0.4 as follow

In controller
Code:
$request = $this->request->getMethod();       
        if ($request == 'post'){
            $form_validation = $this->validate([
                'ID_ASSET' => ['label' => 'Reference', 'rules' => 'required|integer'],]);
        }
        else
        {$form_validation = $this->validate([]);}
if (!$form_validation){}
else{}


in my form
Code:
<?= $validation->listErrors('validation_site'); ?>

And in the view for the errors
Code:
<?php if (count($errors)> 0): ?>
<div class="alert alert-danger" role="alert"> 
    <?php foreach ($errors as $error) : ?>
    <p class="mb-0">
        <i class="mr-1 bx bx-edit"></i><?= esc($error) ?>
    </p>
    <?php endforeach ?>
</div>
<?php endif;?>



RE: Issue with form validation - jreklund - 08-22-2020

@Bart Goossens: Can you please elaborate on what you mean by "strange error"? As you are only showing a possible solution.