Welcome Guest, Not a member yet? Register   Sign In
Validation tutorial
#5

(This post was last modified: 04-23-2020, 08:18 PM by Codinglander.)

We are slowly getting closer Smile

I found two typing errors and now it almost works with validation.

When I call up the form for the first time, I shouldn't get any error messages via
Code:
<?= $validation->listErrors() ?>

But the list of errors is displayed.

If I continue to fill out a few fields, the form should still be "submitted", but I don't get to the success page (where I just want to get the $ _POST array printed).

Where is my mistake?



Here is my updated code:

Controller:
PHP Code:
public function sitesettings()
    {
        $this->validation->setRules([
            'site_admin_name'               => 'min_length[3]|max_length[250]',
            'site_admin_email'              => 'min_length[3]|max_length[250]|valid_email',
            'site_admin_pass_curr'          => 'required_with[site_admin_pass_new,site_admin_pass_new_retype]',
            'site_admin_pass_new'           => 'min_length[8]',
            'site_admin_pass_new_retype'    => 'matches[site_admin_pass_new]',
            'site_name'                     => 'max_length[200]',
            'site_description'              => 'min_length[3]',
            'site_keywords'                 => 'min_length[3]',
            'u_c_reason'                    => 'min_length[3]',
            'u_c_more_infos'                => 'min_length[3]'

        ]);
        if(! $this->validation->withRequest($this->request)->run())
        {
            $this->_set_active(4,1);
            $this->data['main_headline'] = 'Site Settings <small style="color: #6C757D; font-size: 40%">Use the input fields to change value. Keep them clear to change nothing.</small>';
            $this->data['validation'] = $this->validation;
            echo view('admin/sitesettings',$this->data);
        }
        else{
            pre_output($_POST,true);
        }
    
Reply


Messages In This Thread
Validation tutorial - by Codinglander - 04-22-2020, 10:48 PM
RE: Validation tutorial - by Leo - 04-23-2020, 02:51 AM
RE: Validation tutorial - by Codinglander - 04-23-2020, 03:17 AM
RE: Validation tutorial - by jreklund - 04-23-2020, 11:31 AM
RE: Validation tutorial - by Codinglander - 04-23-2020, 07:49 PM
RE: Validation tutorial - by jreklund - 04-24-2020, 09:40 AM
RE: Validation tutorial - by Codinglander - 04-24-2020, 11:12 AM
RE: Validation tutorial - by jreklund - 04-24-2020, 11:21 AM
RE: Validation tutorial - by hugoafr - 07-01-2020, 01:57 PM



Theme © iAndrew 2016 - Forum software by © MyBB