Welcome Guest, Not a member yet? Register   Sign In
Form with POST return null
#1

Hi ,
I have a form with methop post it send the data from the form when put input, but when I do the 
$request->getPost('idiomas') it returns a null.

I have tried with method get and it works but I need to do it in post.

This what the headers infow show me
[Image: Inspector.png]
This is how I create the route
PHP Code:
$routes->post('{locale}/app/admin/edit''Editor::edit', ['namespace' => 'App\Controllers\Appmudet\Admin']); 

And this is the form in html
Code:
<form action="/es/app/admin/edit" method="post">

This is the edit function 
PHP Code:
public function edit(){
        
        
var_dump($this->request->getPost('idiomas'));


    } 
Reply
#2

Did you try using a matched route?

PHP Code:
$routes->match(['get''post'], '{locale}/app/admin/edit''Editor::edit', ['namespace' => 'App\Controllers\Appmudet\Admin']); 
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#3

(This post was last modified: 11-26-2018, 01:25 AM by Perhood.)

(11-23-2018, 09:12 AM)InsiteFX Wrote: Did you try using a matched route?

PHP Code:
$routes->match(['get''post'], '{locale}/app/admin/edit''Editor::edit', ['namespace' => 'App\Controllers\Appmudet\Admin']); 

Yes I have tried it, and the var_dump still show me a NULL
Reply
#4

https://codeigniter4.github.io/CodeIgnit...aceholders

! Note:
{locale} cannot be used as a placeholder or other part of the route, as it is reserved for use in localization.
Reply
#5

(11-26-2018, 08:11 PM)NiteRaven Wrote: https://codeigniter4.github.io/CodeIgnit...aceholders

! Note:
{locale} cannot be used as a placeholder or other part of the route, as it is reserved for use in localization.

I have used it in every route of my web  and it works, I also tried to write the ulr without {locale}, and still dosen't work

Quote:In Routes
The second method uses a custom placeholder to detect the desired locale and set it on the Request. The placeholder 
Code:
{locale}

 can be placed as a segment in your route. If present, the contents of the matching segment will be your locale:


PHP Code:
$routes->get('{locale}/books','App\Books::index'); 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB