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

hello all, Im just moving from CI3 to CI4 , im still playing around with it and;
here some code example

in my controller auth.php
PHP Code:
<?php

namespace App\Controllers;

class 
Auth extends BaseController
{
    public function index($ext null)
    {
        $data = [
            'submit_url'        => base_url('auth/submit'),
            'error'             => $ext['error'],
            'csrf_token'        => csrf_token(),
            'csrf_hash'         => csrf_hash()
        ];
        echo view('inc/header');
        echo $this->parser->setData($data)->render('auth');
        echo view('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 = [
                'error' => $this->validation->getErrors(),
            ];
            return $this->index($ext);
        }
        $email $this->request->getPost('email');
        return $email;
    }


in my view auth.php
PHP Code:
{error}
{
email}
{
password}
{/
error}

<
form class="ui form" method="post" action="{submit_url}">
    <div class="field">
        <label>Email</label>
        <input type="text" name="email" placeholder="Email">
    </div>
    <div class="field">
        <label>Password</label>
        <input type="password" name="password" placeholder="Password">
    </div>
    <input type="hidden" name="{csrf_token}" value="{csrf_hash}" />
    <button class="ui button" type="submit">Submit</button>
</
form


but i get this error after try surfing the page
   


it is same like i did in CI3 when using parser, hope someone can help me. thank you
Reply


Messages In This Thread
Invalid argument supplied for foreach() when using parser - by SkyRipper - 01-23-2020, 12:41 AM



Theme © iAndrew 2016 - Forum software by © MyBB