CodeIgniter Forums
Form with POST return null - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: CodeIgniter 4 (https://forum.codeigniter.com/forumdisplay.php?fid=28)
+--- Forum: CodeIgniter 4 Support (https://forum.codeigniter.com/forumdisplay.php?fid=30)
+--- Thread: Form with POST return null (/showthread.php?tid=72219)



Form with POST return null - Perhood - 11-23-2018

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'));


    } 



RE: Form with POST return null - InsiteFX - 11-23-2018

Did you try using a matched route?

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



RE: Form with POST return null - Perhood - 11-26-2018

(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



RE: Form with POST return null - NiteRaven - 11-26-2018

https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#placeholders

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


RE: Form with POST return null - Perhood - 11-27-2018

(11-26-2018, 08:11 PM)NiteRaven Wrote: https://codeigniter4.github.io/CodeIgniter4/incoming/routing.html#placeholders

! 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');