lundi 30 mars 2015

Is it possible to override Input::old() to null in a model-binded form in Laravel?

I currently have a form built via Laravel that is bound to a model. However, one of my select boxes also has a onChange() event that triggers an AJAX call elsewhere in the page which renders additional form fields specific to what has been selected.


The problem I'm having is that if the select box is already populated (either by pressing the back button or similar), box will be automatically populated with the old input, but the additional questions will not show until the onChange() event is called. I've even tried an onLoad() event, but that doesn't seem to be called for some reason.


I'm sure there's a different approach I could have taken to avoid getting here from the beginning, but the quickest and easiest solution I can think of is to just override the Input::old() that seems to be built in to the model-bound form in Laravel that pre-populates the field. Or I would just have to use a plain Form::open() and put in the Input::old() to all of the other fields.


Here is a snippet of the form I have currently:



{{ Form::model($student, array('route'=>'user.update')) }}
{{ Form::select('major', array(
'major1' => 'major1'
...
), null) }}
{{ Form::close() }}


Thank you very much.


Aucun commentaire:

Enregistrer un commentaire