jeudi 5 janvier 2017

Undefined index error if any element is empty

I am sending 5 input values on single click in angularjs. Data is send as objects of object. For example

Object{0:Object, 1:object, 2:Object .., 5:Object}.

Every object have Two inputs say first name and last name. User can send any input pair.

I am sending this as post request. Now on Backend side, I m using Laravel. I m storing this object in a variable let say `$x=$request->input('data');

I loop it for every object it will create new record.

Problem I am facing: If all objects is sends then it properly saving the data in database. But if one of the object is empty, Empty means if use enter 2nd input and 3rd input only and leave blank the 1st, 3rd and 5th input.

Then laravel throwing error of undefined index as on first object it not receiving any firstname or lastname for 1st request. SO how can I solve this problem.I wanted that it should update the fields whichever it receives.



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/2hZ07wb
via IFTTT

Aucun commentaire:

Enregistrer un commentaire