0

when i try to edit a record, my form does not receive the full text, for example, if in my database I have the string "hello world" in my edit form it will just show me "hello"
edit function

public function edit($id)
{
    $cooperado = Cooperado::find($id);

    return view('cooperados.edit', compact('cooperado'));
}

edit form

  <form method="post" action="{{ route('cooperados.update', $cooperado->id) }}">
    <div class="form-group">
      <label for="name">Nome :</label>
      <input type="text" class="form-control" name="nameCoop" value={{ $cooperado->nameCoop }} />
    </div>
    <div class="form-group">
      <label for="description">Observações :</label>
      <input type="text" class="form-control" name="description" value={{ $cooperado->description }} />
    </div>
  </form>
Rwd
  • 34,180
  • 6
  • 64
  • 78
Jhonatan Mendes
  • 99
  • 2
  • 10
  • 5
    Does `value={{ $cooperado->nameCoop }}` need quotes round the value? – Nigel Ren May 29 '19 at 19:06
  • 3
    Possible duplicate of [How to set HTML value attribute (with spaces)](https://stackoverflow.com/questions/3078192/how-to-set-html-value-attribute-with-spaces) – user3783243 May 29 '19 at 19:19

1 Answers1

1

The problem is that the values should be surrounded by ". See this question.

In your code it should be

value="{{ $cooperado->nameCoop }}"

and

value="{{ $cooperado->description }}"

The " characters tell the browser that the entire attribute value is enclosed between them. Without them, the browser doesn't know where the value ends and where the HTML attributes start.

ollieread
  • 6,018
  • 1
  • 20
  • 36