M
M
miniven2016-03-14 17:22:53
HTML
miniven, 2016-03-14 17:22:53

How to set condition for input value in laravel 5.2?

For example, I am writing a form that I want to use to add a new article and to edit an existing one.
For the new one, everything is clear, the default value can be set to NULL, but if I use it for editing, then I need the default inputs to contain values ​​​​from the database for a specific article. I can write a value specifically for this page, but then the form does not work if I create a new article, because it tries to find the value that I set by default and does not find it (and it is not needed). How to make the input values ​​for a new article be NULL, and for editing they are pulled out of the database?

<div class="form-group">
  {!! Form::label('email', 'E-mail:') !!}
  {!! Form::email('email', $message->email, ['class' => 'form-control', 'placeholder' => 'Ваш email']) !!}
</div>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Victor, 2016-03-14
@miniven

In controller:

return view("myview", ["message" => new Message()]);

E
Eugene, 2016-03-14
@Nc_Soft

Pass class $message empty

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question