CI4 controller can't 'see' a GET parameter - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: CI4 controller can't 'see' a GET parameter (/showthread.php?tid=75440) |
CI4 controller can't 'see' a GET parameter - Ged - 02-06-2020 the form: Code: <form action="/news/create"> the link: https://df2.pennyjack.co.uk/news/create?title=test+title&body=this+is+a+test+body&submit=Create+news+item [url=https://df2.pennyjack.co.uk/news/create?title=test+title&body=this+is+a+test+body&submit=Create+news+item][/url] the check code: PHP Code: public function create() the result: PHP Code: string(19) "this is a test body" It can see the body but not the title. Any idea? Thank you RE: CI4 controller can't 'see' a GET parameter - donpwinston - 02-06-2020 you've got <input type="input" name="title" /> should be <input type="text" name="title" /> RE: CI4 controller can't 'see' a GET parameter - Ged - 02-07-2020 (02-06-2020, 08:20 PM)donpwinston Wrote: you've got <input type="input" name="title" /> should be <input type="text" name="title" /> that's the tutorial and the uri is correctly formed. I've changed it to "text" and the result is the same. The parameter is arriving; the uri is: [/url] Code: https://df2.pennyjack.co.uk/news/create?title=this+is+a+test+title&body=this+is+a+test+body&submit=Create+news+item so it's arriving at the controller correctly. Var_dumping the query object gives: Code: ["query":protected]=> array(3) { ["title"]=> string(20) "this+is+a+test+title" ["body"]=> string(19) "this+is+a+test+body" ["submit"]=> string(16) "Create+news+item" } Accessing 'title' directly from $_GET gives the correct result. Using getVar returns NULL. Do I have to assume it's a bug in the framework? RE: CI4 controller can't 'see' a GET parameter - donpwinston - 02-07-2020 Looks like it. You can try var_dump($this->request->getGet('title')); too. RE: CI4 controller can't 'see' a GET parameter - kilishan - 02-07-2020 getVar() pulls from $_REQUEST. Try dumping out your $_GET and $_REQUEST vars to see what shows up. I don't know of a reason it wouldn't show up in the REQUEST object of the top of my head. Also, as dropwinston said, you can use $this->request->getGet('title') when you know it's coming from $_GET. RE: CI4 controller can't 'see' a GET parameter - Ged - 02-07-2020 (02-07-2020, 12:08 PM)kilishan Wrote: getVar() pulls from $_REQUEST. Try dumping out your $_GET and $_REQUEST vars to see what shows up. I don't know of a reason it wouldn't show up in the REQUEST object of the top of my head. ahh... there is progress. Dumping $_REQUEST gives me: array(3) { ["//news/create?title"]=> string(12) "lkjhlkjhlkjh" ["body"]=> string(16) "4353425435342543" ["submit"]=> string(16) "Create news item" } lkjhlkjhlkjh Ok, not seen that before. Why is the whole uri there for title? |