-
-
Notifications
You must be signed in to change notification settings - Fork 5.2k
[Form] Adding Stimulus code #17364
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
[Form] Adding Stimulus code #17364
Conversation
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.
This looks good to me - just one minor comment :)
I think we can add the remove tags to this PR right now - your approach looks good to me.
"Remove" links: {% for tag in form.tags %}
<li>
{{ form_row(tag.name) }}
<button ...> {# <= Here #}
</li>
{% endfor %} ...which lacks the possibility to "re-remove" a "just-added" item. But it makes the JavaScript so much easier ;-) Bottom line: I haven't thought about how to do something like the current |
I think you could do this with form themes? https://symfony.com/doc/current/form/form_themes.html#fragment-naming-for-collections So, you'd override, for example, a block called |
This is starting to get complicated ;-) So I'd say: Please merge this PR as-is, so we can see what it looks like in practice. And for the "Delete" button, I now see three ways to do it:
So the big question is: Do you want to show all three? |
My vote would be just the form theme. That would also work for the “vanilla javascript” example as well. however, if we want a smaller change for just this PR, I’d vote for adding the delete button via js in the stimulus controller. So, the stimulus version of what’s done in the vanilla js section. I’d really like to not merge this in a half done state - in practice, sometimes that second PR gets delayed and the docs sit in a half done state for too long :) |
Current PR: Sorry, but I've put too much work into some PR's (even on this very page) that were never merged cause in the end somebody said, it's too large and impossible to review (e.g. #10180 (comment) or #11222 (comment)). And when we switch this page to form themes, I fear this will happen again, cause it's going to be a major change (see below). I don't see this PR as incomplete. After all, showing 1 of 2 steps in Stimulus is certainly better than showing 0 of 2 ;-) If we do want to advise people to use form themes, the current section (about adding tags) needs to be refined again - at least this note has to go:
Besides, I would try again to find a way to separate PHP and JavaScript better. |
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.
Fair enough - let's merge in this state, as it is already an improvement, even if we don't yet show how to remove items. We can continue to iterate on it.
65cac34
to
aeb04ec
Compare
Thank you Thomas. |
See #17355 (comment)
Please merge this first, then I'll add the same down at the "Allowing Tags to be Removed" section.