If a relationship is hidden on a resource form does filament still try to submit it?
I have a resource form that when no relationship is set displays a select box but that changes to a section displaying the details once the relationship is set. The problem is when submitting the form I'm getting an error that a null value in the relation violates not-null constraint. Below is the section of the form
Solution:Jump to solution
mutating the form data didn't work but it got me looking at the docs which is when I discovered the ability to conditionally submit the relationship π
2 Replies
You can try to
dd
the subitted data and check whats passing. Just add the method mutateFormDataBeforeCreate
in the Create** in the resource folder.
```php
// in Create(resource name).php EXAMPLE: CreatePage.php
protected function mutateFormDataBeforeCreate(array $data): array
{
dd($data);
}
```
You can check if is null and remove it from the data. Same can be done for Edit.Solution
mutating the form data didn't work but it got me looking at the docs which is when I discovered the ability to conditionally submit the relationship π