Form::file: How to repopulate with Input::old After Validation Errors and/or on Update?

DroBuddy

In my PhotosController, I am trying to modify the edit action so that it shows the existing value in the Form::file() input field (and, so that it repopulates the field if validation fails).

if ($validation->passes())
{
        // saves the image on the FS and updates the db entry
}

    return Redirect::route('photos.edit')
        ->withInput(Input::all())
        ->withErrors($validation)
        ->with('message', 'There were validation errors.');

The uploading process works fine, but when I view an existing record, or if validation fails upon creation, the Form::file doesn't show the value. I looked up the method in the api, and it only accepts the name and optional options arrays. Whereas, the other methods in the FormBuilder class allow us to set the value using Input::old().

I've tried passing in the following values to withInput, but they've been to no avail: * Input::all() * Input::old() * Input::except('photo_path') * Input::get('photo_path')

How can I update this so that if validation fails, or if a user views an existing record, the Form::file() method will show the existing value?

I'm sure that I'm overlooking something incredibly simple because I haven't found other threads of people asking this...

Needpoule

Apparently you can't. Browsers don't allow you to set a value on a file input for security reasons.

There are two silimar questions, not laravel related but i think answers could help you:

Can you re-populate file inputs after failed form submission with PHP or JavaScript?

Restoring the value of a input type=file after failed validation

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How to repopulate a form with latest changes after validation failure during update in laravel 5

How to show the input type file value after form is submited and there are errors?

Pass old input after Form Request validation in laravel 5

Remember and Repopulate File Input

how to repopulate a form in codeigniter

How to fix React Form input not hiding validation errors

how to clear validation errors for mat error after submitting the form

How to keep value for file when submit form due validation errors

Repopulate Select Multiple in For loop after validation

Ruby on Rails validation on input form generating errors

How to input a calculated value after form validation in zf2

IE - How to disable validation detection from input after submitting the form?

Multiple file input and form validation?

Handling Errors inside OnValidSubmit, After Form Validation

how to set value of form input fields and re-check their form validation errors

NodeJS Express: Repopulate form after error found

Laravel validation with create form: retrieve old input data for dropdown box

How to render validation errors of form partial - Rails

How to redirect after form validation?

How to stop the form input type select data from erasing after PHP form validation?

how to repopulate /etc/asterisk/ after purging asterisk?

How to show the old data in a form input in the Laravel

How to maintain the old input value in checkbox after validating by an update request using laravel?

Unable to repopulate values after xml validation in Struts2

How to remove errors in after_validation in Rails

Angular - How to stop trigger all form field validation when update a single input

multiple form submits after fixing html5 validation errors

Angular 2 display validation errors after form submit

Validation errors not showing after I ajax a rails form

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    pump.io port in URL

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  14. 14

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  15. 15

    How to use merge windows unallocated space into Ubuntu using GParted?

  16. 16

    flutter: dropdown item programmatically unselect problem

  17. 17

    Pandas - check if dataframe has negative value in any column

  18. 18

    Nuget add packages gives access denied errors

  19. 19

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  20. 20

    Generate random UUIDv4 with Elm

  21. 21

    Client secret not provided in request error with Keycloak

HotTag

Archive