using the example from the backpack documentation,
i have the following tables:
invoices: id, number, due_date, payment_status, other fields... invoice_items: id, order, description, unit, quantity, unit_price
and the following fields:
CRUD::field([
'type'=>'date_picker',
'name'=>'due_date',
'label'=>'Due Date',
]);
<--- other fields --->
CRUD::field([
'name' => 'items',
'type' => "relationship",
'subfields' => [
[
'name' => 'order',
'type' => 'number',
'wrapper' => [
'class' => 'form-group col-md-1',
],
],
[
'name' => 'description',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-md-6',
],
],
[
'name' => 'unit',
'label' => 'U.M.',
'type' => 'text',
'wrapper' => [
'class' => 'form-group col-md-1',
],
],
[
'name' => 'quantity',
'type' => 'number',
'attributes' => ["step" => "any"],
'wrapper' => [
'class' => 'form-group col-md-2',
],
],
[
'name' => 'unit_price',
'type' => 'number',
'attributes' => ["step" => "any"],
'wrapper' => [
'class' => 'form-group col-md-2',
],
],
],
]);
how can i save the due_date field together with the relationship subfields in the invoice_items table?
i tried to override the store method but i get duplicate data in the invoice_items table
I would suggest creating a hidden "due_date" field within the subfields and updating them using the CrudFields JS library:
https://backpackforlaravel.com/docs/6.x/crud-fields-javascript-api
The way it would work:
Let me know if this helps!