Simple form doesn't redirect to action
Created 6 years ago by gonziisI have made a module in which view I made a simple form which is supposed to redirect to specific method in controller with a POST method.
<form method="post" action="/report/create" name="reportform">
<div class="form-group">
<label for="test1">1. Kurš uzņēmums (vai uzņēmumi), Jūsuprāt, pārkāpis likumu?</label>
<input type="text" class="form-control" name="q1" id="test1">
</div>
<div class="form-group">
<label for="test2">2. Uz kuriem produktiem vai pakalpojumiem pārkāpums attiecas?</label>
<input type="text" class="form-control" name="q2" id="test2">
</div>
<div class="form-group">
<label for="exampleInputPassword1">3. Kāda bija Jūsu saskare ar pārkāpēju? Jūs bijāt:</label>
<div class="radio"><label><input type="radio" name="saskare" value="1"><span class="checkmark"></span>Klients</label></div>
<div class="radio"><label><input type="radio" name="saskare" value="1"><span class="checkmark"></span>Konkurents</label></div>
<div class="radio"><label><input type="radio" name="saskare" value="1"><span class="checkmark"></span>Cits variants</label></div>
<input type="text" name="saskare_t" class="form-control" id="exampleInputPassword1">
</div>
<div class="form-group">
<label for="test3">4. Lūdzu aprakstiet, kā izpaudās pārkāpums? Kur un kad tas notika?</label>
<textarea class="form-control" name="q4" id="test3" rows="3"></textarea>
</div>
<div class="form-group">
<label for="test3">5. Vai Jūsu rīcībā ir dokumenti.</label>
<textarea class="form-control" name="q5" id="test3" rows="3"></textarea>
<button class="purple green">Pievienot dokumentus</button>
</div>
<div class="form-group">
<label for="test3">6. Ja vēlaties, varat norādīt savu kontaktinformāciju</label>
<textarea class="form-control" name="q6" id="test3" rows="3"></textarea>
</div>
<input type="submit" class="purple" name="submit" value="Iesniegt ziņojumu"/>
</form>
I know this isn't the best of creating forms, but shouldn't this work too? I have a simple report controller with 2 methods
public function index(ReportRepositoryInterface $reports, Request $request)
{
//dd($request->getMethod());
return $this->view->make("mendo.module.report::reports/index");
}
public function create(ReportRepositoryInterface $reports, Request $request)
{
die();
dd($request->getMethod());
}
As you can see, the form is directed to create, but it doesn't die()
, it just redirects to reports/index. Also when I debug the request method in index method, it shows GET
not POST
.
Also I have defined the route for index and create in ReportModuleServiceProvider.php
protected $routes = [
'report' => 'Mendo\ReportModule\Http\Controller\ReportController@index',
'report/create' => 'Mendo\ReportModule\Http\Controller\ReportController@create',
'admin/report' => 'Mendo\ReportModule\Http\Controller\Admin\ReportsController@index',
'admin/report/create' => 'Mendo\ReportModule\Http\Controller\Admin\ReportsController@create',
'admin/report/edit/{id}' => 'Mendo\ReportModule\Http\Controller\Admin\ReportsController@edit',
];
What is wrong here exactly? Normal forms just don't work in this environment or what is the problem exactly?