Я могу клонировать поле выбора из того места, где я не уверен, как мне добавить другое содержимое (поля ввода)
Я заполняю содержимое опции выбора, используя данные из контроллера.
Blade
<div class="container">
<div class="invoice-box">
<form action="" method="POST">
@csrf
<table cellpadding="0" cellspacing="0">
<tr class="top">
<td colspan="5">
<table>
<tr>
<td class="title">
<img src="{{asset('assets/Say-cure-final-logo.png')}}"
style="width:100%; max-width:150px;">
</td>
<td>
Invoice #{{$orderid}} <br> Created: {{Carbon\Carbon::now()->format('M d, Y')}}<br> Due:
{{Carbon\Carbon::now()->format('M d, Y')}}
</td>
</tr>
</table>
</td>
</tr>
<tr class="information">
<td colspan="5">
<table>
<tr>
<td>
{{env('APP_NAME')}}<br> {{env('COMPANYADDRESS')}}<br> {{env('COMPANYADDRESSLINE')}}
<br>
{{env('COMPANYDISTRICT')}}, <br> {{env('COMPANYSTATE')}}, {{env('COMPANYPINCODE')}}
</td>
<td>{{$order_details['order_details']->full_name}}
<br>{{$order_details['order_details']->address_line_1}}
<br>{{$order_details['order_details']->land_mark}},{{$order_details['order_details']->area}}
<br>{{$order_details['order_details']->district}},{{$order_details['order_details']->city}}
<br>{{$order_details['order_details']->state}},{{$order_details['order_details']->pincode}}
<br>{{$order_details['order_details']->email}} <br>
{{$order_details['order_details']->phone_no}}
</td>
</tr>
</table>
</td>
</tr>
<tr class="heading">
<td colspan="4">
Payment Method
</td>
<td>
{{$order_details->payment_mode}}
</td>
</tr>
<tr class="details">
<td colspan="3">
</td>
<td>
{{$order_details->payment_paidamount}}
</td>
</tr>
<tr class="heading">
<td>
Item
</td>
<td>
Unit Cost
</td>
<td>
Quantity
</td>
<td>
Price
</td>
<td>
Action
</td>
</tr>
<tr class="item">
<td>
<div class="input-field col s12 ">
<select class="invoice-select">
@foreach ($products as $product)
<option value="{{$product->id}} ">{{$product->product_name}} </option>
@endforeach
</select>
<label>Products</label>
</div>
</td>
<td>
<div class="invoice_amount">
₹<input type="number" value="{{$order_details->payment_paidamount}}" />
</div>
</td>
<td>
<div class="invoice_quantity">
<input type="number" value="1" />
</div>
</td>
<td>
<div class="invoice_total">
$300.00
</div>
</td>
<td colspan="4">
<button class="btn btn-add-row">Add row</button> /
<button class="btn" id="btn-remove-row"> Remove</button>
</td>
</tr>
</table></form>
</div>
</div>
Сценарий
$('.btn-add-row').on('click', (e) => {
e.preventDefault();
var $lastRow = $('.item:last');
var $selectRow = $lastRow.find('.invoice-select:last');
var $newRow = $selectRow.clone();
console.log($newRow.find('.invoice-select:last').attr("class","invoice-select"));
$('.invoice-select').formSelect();
$newRow.insertAfter($lastRow);
});
$( window ).on( "load", function() {
console.log( "window loaded" );
$('.invoice-select').formSelect();
});
Я не могу заполнить поля ввода, кроме выбора , Также как мне сохранить данные в базе данных.