-
Notifications
You must be signed in to change notification settings - Fork 32
Custom attrs for field #9
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
base: master
Are you sure you want to change the base?
Conversation
Implemented tag for custom css class for input field
|
I have mixed feelings about this PR. On one hand I get that attributes can be handy with some JS libraries, but on the other hand this was meant to be a fairly simplistic library and this starts to complicate things. One thing I can say with certainty is that I don't care for the use of JSON in the struct tag. eg: I get why you used it, but I think that format is awful to read and will be problematic long term. If allowing for attributes like these, I suspect a better approach might be to allow struct tags of the format I suspect this still might lead to edge cases that don't work well, but at the very least it follows an approach similar to all of the other HTML attributes. Alternatively, I might see an argument for just exposing all extra struct tags to the HTML template as a map of key/values. In that case the Would potentially allow for HTML roughly like: This would also eliminate the need for anymore PRs like this for random edge cases, as you could also use the |
|
I think, I got better idea Your lib doesn't has layout of form, only for input. In this case, my proposal add layout of form. Default mode Layout mode For example In layout form we generate next function Also we can build own input widget So, Want to hear you opinion? What do you think about it? PS: this idea resolve in symfony form. |
|
If you would like to add major functionality like this, my suggestion is to
fork the library and continue development with your own fork.
It isn't that I dislike exploring these ideas, but I do not have the time
for it right now. Even if you coded all the changes yourself, I would still
need to review the PR, make sure I understand what the changes do and why
they are being added, then after merging I would need to maintain and fix
any bugs that extend from the changes. All of those are things I don't have
the capacity for at the moment.
…On Thu, Oct 13, 2022 at 8:40 AM Vladimir ***@***.***> wrote:
I think, I got better idea
Your lib doesn't has layout of form, only for input.
How to resolve form in two columns, or first line one column, second line
- two columns, html code, third line one column.
In this case, my proposal add layout of form.
*Default mode*
we can use InputTemplate and render form as {{ inputs_for . }}
*Layout mode*
we generate template functions by each struct field, and we can build form
manually
For example
type Member struct {
Id int
Name string
}
In layout form we generate next function
{{fieldName}}_row - render input using template from InputTemplate
Also we can build own input widget
{{fieldname}}_label - input's label
{{fieldname}}_errors - input's errors
{{fieldname}}_widget - render input *and in this function we can pass
arguments like as custom css classes, attributes etc.*
{{fielname}}_footer - input's footer attributes
So, Want to hear you opinion? What do you think about it?
In this way, we ignore add new tags in struct field, and keep small. But
if we need more feature, we can use layout mode and build form manually
PS: this idea resolve in symfony form
<https://symfony.com/doc/current/form/form_customization.html#form-rendering-functions>
.
—
Reply to this email directly, view it on GitHub
<#9 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMZT6KIR7RJ7EIIWKNJM7TWC77LTANCNFSM6AAAAAARDUTZQU>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
I think, set custom attrs in json format is friendly and shortest way.
If you don't think so, let me know