T
T
Troodi Larson2018-10-01 21:28:47
Laravel
Troodi Larson, 2018-10-01 21:28:47

How to write old, value from the model, or empty value to the input?

There is an input with value="{{ old('name') }}"located on the /test page, if there is an error in value, the old value will be. It is necessary to make sure that when opening / test / 2, information from the model is already written there. And you need to use one template.
You can, of course, shove this field into yield and, depending on /test or /test/2, change it using @section, but maybe there is an easier way?
Structure:
test.blade.php with @extends('index')
test2.blade.php with @extends('index')
index.blade.php with the form itself.
It would be desirable that the form for creation and editing was the same. Now I change everything through yield.
It roughly looks like this:

try{
  echo old(name', $input->name); //$input->name не существует, пока не передали из контроллера
} catch() {
  echo old(name');
}

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
anlamas, 2018-10-02
@troodi

If I understood you correctly, then you just need to write
That is, when submitting the form, if there is an error, it will show what the user entered, and so it will show the value of the model.
You don't need LaravelCollective

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question