filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
18.98k stars 2.93k forks source link

model object is not available in CreateRecord::beforeValidate() #8939

Closed fazliddin closed 1 year ago

fazliddin commented 1 year ago

Package

filament/forms

Package Version

v3

Laravel Version

v10

Livewire Version

v3

PHP Version

v8

Problem description

protected function beforeValidate(): void
{
   $this->getRecord()
}

This returns null, which makes this function useless.

Expected behavior

$this->getRecord() must return object.

Steps to reproduce

Solution is that CreateRecord::handleRecordCreation must be splitted into two parts.

  1. Create model object
  2. Call all hooks so that they modified object
  3. Save model object

Reproduction repository

https://github.com/filamentphp/filament

Relevant log output

No response

github-actions[bot] commented 1 year ago

Hey @fazliddin! We're sorry to hear that you've hit this issue. 💛

However, it looks like you forgot to fill in the reproduction repository URL. Can you edit your original post and then we'll look at your issue?

We need a public GitHub repository which contains a Laravel app with the minimal amount of Filament code to reproduce the problem. Please do not link to your actual project, what we need instead is a minimal reproduction in a fresh project without any unnecessary code. This means it doesn't matter if your real project is private / confidential, since we want a link to a separate, isolated reproduction. That would allow us to download it and review your bug much easier, so it can be fixed quicker. Please make sure to include a database seeder with everything we need to set the app up quickly.