populate backend create form

- 1 answer

Ad

With the builder tool i created a standart backend form for my Customer model.

When I display the related create page (with url like .../myadmin/author/myplugin/customers/create), in some case, I need to be able to populate some text fields with predefined values (from an oldCustomer model precisely)

I tried a system D tech by forcing a value in my session or in my input but that does not work

my try with session

Session::flash('email', '[email protected]');
return Redirect::to('/myadmin/author/myplugin/customers/create');

or with input option

Input::flashOnly('email', '[email protected]');
return Redirect::to('/myadmin/author/myplugin/customers/create')->withInput();

which gives the following result in my session debugbar tab

_old_input  array:2 [ "email" => null "[email protected]" => array:1 [ "com" => null ] ]

here we can see email is set but with null value then after this is whatever.

i feel i'm not so far but already spending half a day on it ! thanks for help

Ad

Answer

Ad

You can set the default values in the model constructor.

Check the session for the old value and if it exists, populate the required fields with the data.

Ad
source: stackoverflow.com
Ad