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

Disable certain attribute fields when editing #1691

Open
wants to merge 2 commits into
base: 1.x
Choose a base branch
from

Conversation

alecritson
Copy link
Collaborator

The hub doesn't really support the changing of certain attribute columns once hey have been created. This is because it's hard to keep the attribute_data in sync with what the new fieldtype might require, leading to quite an overhead for something seemingly simple.

This PR will disable the handle and type columns when editing an attribute to preserve and prevent data issues. If a developer needs to change the fieldtype then it should be done in a migration or similar so that appropriate steps can be taken to ensure the data is migrated properly.

As a side effect this should close #1655

Copy link

vercel bot commented Apr 11, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
lunar-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 23, 2024 8:12am

@glennjacobs glennjacobs added this to the v1.0 milestone Apr 12, 2024
@wychoong
Copy link
Contributor

this might not solve the issue of changed attribute type.
for example, if the user is using the panel purely, and created a TranslatedText attribute summary, and later on deleted it, and created new TextField with the same handle summary. It essentially is the same of changing the attribute type, and the form is generated as TextField input but the data is cast/hydrated as TranslatedText

probably should add a checker/validate in formatStateUsing to nullify it if the type is different

->formatStateUsing(fn ($state) => ($state ?: new $attribute->type))

if adding a new method to FieldTypes, maybe we can have a sort of transformer to handle a basic conversion like "text field value" -> ['en' => "text field value"] and vice versa

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error when saving a product with a Lunar\FrieldTypes\TranslatedText attribute
3 participants