Skip to content
New issue

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

Custom Attribute File Field Type Fails to Save Due to Strict Type Comparison in AttributeData #2091

Open
Huncsuga opened this issue Feb 3, 2025 · 1 comment
Labels
bug Something isn't working unconfirmed

Comments

@Huncsuga
Copy link

Huncsuga commented Feb 3, 2025

  • Lunar version: 1.0.0-beta.6
  • Laravel Version: 11.35.1
  • PHP Version: 8.3.15
  • Database Driver & Version: MySQL 8

Expected Behaviour:

When creating a custom attribute file field type by following the documentation, the file should be correctly saved, and its reference should be stored in the database.

Actual Behaviour:

When attempting to save a custom attribute file field type, an error occurs. The issue seems to stem from the AttributeData class, specifically in the ->mutateDehydratedStateUsing method. There is an if condition that checks:
if ($attribute->type == FileFieldType::class)
Since a custom attribute file field type is not strictly equal to FileFieldType::class, this condition does not execute.

Steps To Reproduce:

  1. Follow the Lunar documentation to create a custom attribute field type for a file upload.
  2. Attempt to save a record with this custom file field type.
  3. Observe that an error occurs because the if condition does not account for custom file field types.
@Huncsuga Huncsuga added bug Something isn't working unconfirmed labels Feb 3, 2025
@tdwesten
Copy link

tdwesten commented Feb 4, 2025

Yeah, I think this is related to #2071.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working unconfirmed
Projects
None yet
Development

No branches or pull requests

2 participants