Answer the question
In order to leave comments, you need to log in
Why is the request to edit the news not sent?
The third hour I can not solve the problem, there are news on the site, and each news has the "Delete" and "Edit" buttons. So, when you go to the localhost:8000/news/1/edit page , everything is fine, but the request to change the news is not sent.
news is the route/1 is the id of the news/edit is the edit page.
I thought the problem was in POST-GET, but no.
The "Editing" page of the news itself:
<div class="edit-news">
<h2 class="text-center">Редактирование: <b>{{ $news->title }}</b></h2>
<form method="PUT" action="{{ route('news.update', $news->id) }}">
<div class="form-group">
<label for="title">Название:</label>
<input class="form-control" placeholder="Введите названия" name="title" type="text" required autofocus
>
</div>
<div class="form-group">
<label for="description">Описание новости:</label>
<p><textarea name="description" id="description" cols="30" rows="10" required></textarea></p>
</div>
<br>
<div class="form-group">
<label for="full_description">Полное описание новости:</label>
<p><textarea name="full_description" id="full_description" cols="30" rows="10" required></textarea></p>
</div>
<br>
<div class="form-group">
<label for="author">Автор:</label>
<input class="form-control" placeholder="Введите автора" name="author" type="text" required>
</div>
<div class="form-group">
<input type="submit" class="btn btn-success" value="Сохранить">
</div>
</form>
</div>
public function update($id, PublishNewsRequest $requestData)
{
$news = News::find($id);
$news->title = $requestData['title'];
$news->description = $requestData['description'];
$news->full_description = $requestData['full_description'];
$news->author = $requestData['author'];
$news->save();
return redirect()->route('news.index');
}
Answer the question
In order to leave comments, you need to log in
HTML forms do not support PUT, PATCH or DELETE actions. So, when defining PUT, PATCH or DELETE routes that are called from an HTML form, you will need to add a hidden _method field to the form.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question