marvinlabs / laravel-html-bootstrap-4

Bootstrap 4 fluent HTML builder
MIT License
42 stars 15 forks source link

old() function does not work with arrays #47

Closed JamesPoel closed 4 years ago

JamesPoel commented 6 years ago

Example:

{{ bs()->text('profile[first_name]', $user->first_name) }}

If you submit a form containing the above, and there is a validation error, the value previously inputted into the form is not loaded back into the field.

Caused by ln 31 of OldFormInputProvider.php. return $this->request->old(field_name_to_id($key), $default);

field_name_to_id($key) translates to "profile_first_name", wheras it should be "profile.first_name".

Changing the line to simply return $this->request->old($key, $default);, solves the issue.

vpratfr commented 6 years ago

Hi,

would you be able to submit a PR for a fix?

JamesPoel commented 6 years ago

Done

JamesPoel commented 5 years ago

Still not merged, causing a fair bit of problems :( Had to edit the file directly for now... ha