php - Repeating Form Fields In Laravel -
I have a form that is collecting data on 2 different models.
Model Sale comes under ITM Sales There are many sales sales in a sale
I know I need to bring the repeating areas to the array, but I Not sure how I should go about doing this. Although I had the right idea, but my controller is not holding the array as a variable which I was trying to install it.
You can see the relevant code here:
All help is appreciated!
/ *** Sales Model *** / Category Sale is Expanded User_id = $ userID; } $ Sale- & gt; Invoice_enumber = input :: receive ('invoice_number'); $ Sale-> Name_of_purchaser = input :: get ('name_of_purchaser'); $ Sale-> Date_of_sale = input :: get ('date_of_sale'); // For every sale that is present in the foreign currency ($ item as $ item) {// new sales sale $ sales item = new selistimes (); // Save Features $ Sale Item- & gt; Product_id = $ item ['Tools']; $ Laitime-> Sales_price = $ item ['sales_pres']; $ SaleItem-> Serial_number = $ item ['serial_number']; $ SaleItem-> Save (); // Collaborative $ sales with sales- & gt; Sales item () - & gt; Associate ($ sales item); } $ Sales- & gt; Save (); Return "Sale Saved"; } / **** Sell / create.blade.fp ***** / {{form :: open (array ('action' => 'SalesController @ store'))}} First ('Invoice_number', ' First ('name_of_purchaser', ' First ('date_of_sale', ' First ('tool', ' First ('sales_pris', ' First ('serial_number', 'small square = "error" & gt;: message & lt; / small & gt;'}}} & lt; / Li & gt; & Lt; Li & gt; & Lt; Button href = "#" class = "add" rel = ".clone" & gt; & Lt; I class = "fa-plus-squire" & gt; & Lt; / I & gt; Add item & lt; / Button & gt; & Lt; / Li & gt; & Lt; / Ul & gt; & Lt; / Li & gt; & Lt; Li & gt; {{Form: Submit ($ button text)}} & lt; / Li & gt; & Lt; / Ul & gt; {{Form :: close (); }} / **** Obtaining this error Undefined variable: items * /app/controllers/SalesController.php **** /
OK, you have some errors in your code, but I will try to give you a direction.
Change the input field like this : <{Form :: text ('item [0] ["device"]', array ('class' => form-control clone'))}}. ... {{form :: text ('items [0] ["sales_pres"]', array ('class' => 'form-control clone'))} } ....
- $ items = input :: get ('items'); grab objects; (BTW this is a point where php has thrown an error: you do not get $ items from the request)
Wade on the item array and add each one to your sales model ..
Comments
Post a Comment