We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I have an Invoice model and an InvoiceDetail models defined like so:
// Invoice.php protected $casts = [ 'invoiceDetails' => 'array', ]; public function invoiceDetails() { return $this->hasMany(InvoiceDetail::class); }
// InvoiceDetails.php public function invoice() { return $this->belongsTo(Invoice::class); }
In my InvoiceCrudController I added this field:
CRUD::addField([ 'name' => 'invoiceDetails', 'label' => __('Products'), 'type' => 'relationship', 'subfields' => [ [ 'name' => 'product_name', 'type' => 'text', 'label' => __('Product'), 'wrapper' => ['class' => 'form-group col-md-8'], ], [ 'name' => 'quantity', 'type' => 'number', 'label' => __('Quantity'), 'attributes' => ['step' => '0.01', 'min' => 1], 'wrapper' => ['class' => 'form-group col-md-2'], ], [ 'name' => 'price', 'type' => 'number', 'attributes' => ['step' => '0.01'], 'label' => __('Price'), 'wrapper' => ['class' => 'form-group col-md-2'], ] ], 'tab' => __('Products'), 'init_rows' => 0, ]);
I tried to use the new features of the "relationship" field as described here
I got this error:
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'invoice_id' cannot be null update `payments` set `invoice_id` = ?, `payments`.`updated_at` = 2022-02-20 08:28:30 where `invoice_id` = 1130
BAckpack 5.0.7, PHP 8.0
The text was updated successfully, but these errors were encountered:
Hello @thdebay
Thanks for the report. Can you please confirm me if this happens when you delete the relation ?
If so, there is already a PR open that we are polishing and settling on the best solution that will fix this issue: #4205
If that is not the case, I could NOT replicate it yet then!
Cheers, Pedro
Sorry, something went wrong.
Perfect, I didn't notice there already was an open PR about this. My issue is now solved. Thank you @pxpm !
pxpm
No branches or pull requests
Bug report
What I did
I have an Invoice model and an InvoiceDetail models defined like so:
In my InvoiceCrudController I added this field:
What I expected to happen
I tried to use the new features of the "relationship" field as described here
What happened
I got this error:
Backpack, Laravel, PHP, DB version
BAckpack 5.0.7, PHP 8.0
The text was updated successfully, but these errors were encountered: