{{old('element_name'}} command return the old value of element in page , so in form validation if validation failed I can show the user , value entered and form element value remain.
how i could get the list of all old value in form ? may be something like this (old function without parameter)
<script>
var list_of_all_old_value = {{ old() }};
</script>
thank's jlrdw
I have java script function that get the list of all select box on the form with options of each select box and fill all select box , in addition that function get the model object from controller (*.php) to select proper option in each select box,
problem is when user change the one select box options to something else if validation failed , keep selected option on the form (keep old value), thing is that I write just one function to use in all form , so I want to retrieve the list of all old selected option
$(document).ready(function () {
var selboxinfo ={!! $SelBoxInfo !!};//key value array [select box name=>[array of option] ]
var UpdateEntObj ={!! $ModelObj ?? '0' !!};
for (var sel_box_name in selboxinfo) {
var selboxvaluelist = selboxinfo[selboxname];
var dropdown = $("#" + sel_box_name);//find related dropdown in form
let entitykeyvalue = (UpdateEntObj!=0) ? UpdateEntObj[selboxname] : -1;
if(entitykeyvalue==-1)
{
//if there is no modelObj check old value
entitykeyvalue= "{{old(sel_box_name) ?? -1}}";//??? sel_box_name is undefined ERORR
//sel_box_name is client side variable.
//OK so I want to have list of all old value and search on
//them
}
dropdown.empty();
$.each(selboxvaluelist, function (key, value) {
dropitem=new Option(value,key);
dropitem.selected=(key==entitykeyvalue);
dropdown.append(dropitem);
});
}
});