-
Notifications
You must be signed in to change notification settings - Fork 68
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
DOC Document including attributes in formfield schema data #630
Merged
emteknetnz
merged 1 commit into
silverstripe:6
from
creative-commoners:pulls/6/schemadata-attributes
Nov 24, 2024
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems like this solution may be worse than the status quo?
This would mean that (to be fair, probably a small number) of sites will get a possibly very hard to diagnose infinite loop when they upgrade to CMS 6, and, they have to put some HTML attributes separately in the template, which seems slightly worse IMO than having them done separately in PHP. In PHP you can at least do things like just do the "manual workaround" in a super class and have it inherited?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's probably all kinds of errors that can occur when doing a major upgrade if you don't take care to read through the changelog and check for instances of the things it calls out.
I think that's to be expected.
They're data attributes that can't be added in another way without stopping attributes from being usable in react form fields. A very minor inconvenience for unlocking what should be a no brainer - setting attributes on the form field and seeing them used in those form fields.
I'm not sure what you mean by this, but people shouldn't have to make subclasses of built in fields just to get
setAttribute()
to work.Before, attributes would not be pulled through to the react fields. Now they are. Seems like it's better, not worse?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would something like this work? It would prevent the need to update templates
And then remove 'data-schema' + 'data-state' from all the FormField subclasses getAttributes() ?
May result in adding too many 'data-schema' + 'data-state' attributes to fields that don't actually use them, though could add
protected bool $includeSchemaAttributes = false
to FormField and set to true on subclasses that need themThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand how the
data-schema
anddata-state
would get to the template, in that case?You'd also introduce a new infinite loop: getSchemaDataDefaults -> getSchemaAttributes -> getSchemaData -> getSchemaDataDefaults
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh true :-)
Perhaps just have getSchemaAttributesHTML() as a public method on FormField and in the template just go $SchemaAttributesHTML on the templates that need it, it's a little confusing right now that some of them don't include data-state while some do, easier to just always include it even if it's unused by the react component
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That seems fine to me that fields which need it will have it, and those which don't need it don't have it.
Just to clarify... are you asking me to add:
If so, that just seems to me like a worse version of what this PR already does, but I'll do it if that's what you need to approve this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, add a new public method, and use it on those templates where you've made changes e.g. SearchableDropdownField.ss, though don't add it to FormField templates that simply don't need the schema attributes though.
I think that's an improvement because that way we won't look at this at the templates in the future and go "Why isn't data-schema just in getAttributes()?". Would also be worth adding a comment to the new method saying this exists to prevent an infinite loop
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done