-
Notifications
You must be signed in to change notification settings - Fork 34
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
add selectFieldTag helper #118
base: main
Are you sure you want to change the base?
Conversation
Looks like test coverage still needs a little work. |
Even in Perl i've never actually used the |
Perhaps this would be better off in a plugin. Would also make documenting the complex usage more straight forward. 🤔 |
About the complexity, may I suggest to implement it in a very different way, more like a That would be something like:
Despite being very different from Perl implementation, I think it would be much easier to understand and document. Implementation should be very easy too, just looking at formFor code it should be just one line. It would benefit from the existence of Template Blocks to generate the content inside Also an Then there is the issue about pre-populating the selected option(s) according to current data when rendering an edit form, but this is something probably needs more discussion. |
Separating |
mmm not sure about that. I see it like the |
About the purpose of using tags, for me one reason to use Consider as a reference the
But this has a problem because the existing value for the What we have to do is to add some template coding to include a "selected" attribute on the option with the So it would be nice if the option tag somehow helps us on this issue. Also probably something could be done with the other input tags, as passing the |
The |
Proposal to implement the
selectFieldTag
helper.The implementation aims to keep some consistency between mojo.pl and mojo.js templates for the select_field helper.
Key Points:
selectFieldTag(name, [array of options], attributes)
label
optgroup attribute. After that, element are treated as normal option items. After the array you can include an object with optgroup desired attributes.Test cases for mojo.pl translations are as follows:
... translates to mojo.js:
multiple
attribute:... translates to:
disabled
attribute:translates to:
...translates to: (uses a nested array for group)
...translates to: