0
I have an edit form for a post feed. When I click to save the edit the following error appears:
SQLSTATE[23502]: Not null violation: 7 ERROR: null value in column "title"
violates not-null constraint
DETAIL: Failing row contains (1, 1, null, null, null, 2018-04-24 10:04:55).
(SQL: update "feeds" set "title" = , "description" = , "updated_at" = 2018-
04- 24 10:04:55 where "id" = 1)
It’s like I’m sending you blank information, but there’s nothing blank.
feed-update.blade.php
@extends('layouts.app')
@section('content')
<div class="container">
<form action="<?php echo action('HomeController@save', $feed->id); ?>" method="POST">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?> ">
<h1>Editar Post</h1>
<b>Publicado por: {{$feed->user->name}} </b><br>
<b>Título:</b><input class="form-control" type="text" value="{{$feed->title}}">
<br>
<b>Descrição:</b><input class="form-control" type="text" value="{{$feed->description}}">
<br>
<button type="submit" class="btn btn-success">Salvar</button>
</form>
</div>
@endsection
Homecontroller@save
public function save($idFeed)
{
$title = Request()->input('description');
$description = Request()->input('title');
$feed = feed::find($idFeed);
$feed->description = $description;
$feed->title = $title;
$feed->save();
return redirect()->action('HomeController@index');
}
Another point is the $title inversion receiving the Description field.
– Jonathan de Toni
It worked, thank you.
– João.Mistura
Yeah, I just tidied up.
– João.Mistura