Welcome Guest, Not a member yet? Register   Sign In
Invalid argument supplied for foreach() when using parser
#5

no solution yet, currently I'm using this way to solve my problem

PHP Code:
<?php

namespace App\Controllers;

class 
Auth extends BaseController
{
    public function index()
    {
        $data = [
            'submit_url'    => base_url('auth/submit'),
            'csrf_token'    => csrf_token(),
            'csrf_hash'     => csrf_hash(),
            'responses'     => $this->session->getFlashdata()
        ];
        echo $this->parser->setData($this->header)->render('inc/header');
        echo $this->parser->setData($data)->render('auth');
        echo $this->parser->setData($this->footer)->render('inc/footer');
    }

    public function submit()
    {
        $this->validation->setRules([
            'email'         => 'required|valid_email',
            'password'      => 'required',
        ]);
        $valid $this->validation->withRequest($this->request)->run();
        if ($valid === false) {
            $ext = [
                'email'     => $this->validation->getError('email'),
                'password'  => $this->validation->getError('password'),
                'message'   => ''
            ];
            return redirect()->back()->with('error'$ext);
        }
        $email $this->request->getPost('email');
        return $email;
    }


but this way not really nice since I need to declare each error to their own var rather than using array.
Reply


Messages In This Thread
RE: Invalid argument supplied for foreach() when using parser - by SkyRipper - 02-23-2020, 07:49 PM



Theme © iAndrew 2016 - Forum software by © MyBB