-
-
Notifications
You must be signed in to change notification settings - Fork 256
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
Incorrect label for belongs_to selects #1929
Comments
Hi @xeron good catch! My browser do not complains about it, I'm using Firefox. Also tried with Chrome, didn't complained at all.
What do you mean? It works as expected on my end. Anyway good catch again, the label's |
Thanks you for the clarification! |
It's been a while since I reported this. Could someone take a look? I checked the code but I don't really understand where this part comes from. |
Well I know select id comes from here, but if I change it to
Something like this fixes the issue but I feel like this is not a proper fix: diff --git a/app/components/avo/field_wrapper_component.html.erb b/app/components/avo/field_wrapper_component.html.erb
index e044301b..61b22803 100644
--- a/app/components/avo/field_wrapper_component.html.erb
+++ b/app/components/avo/field_wrapper_component.html.erb
@@ -11,7 +11,8 @@
"md:w-64": !compact?,
}), data: {slot: "label"} do %>
<% if form.present? %>
- <%= form.label field.id, label %>
+ <% id = field.class == Avo::Fields::BelongsToField ? "#{field.id}_id" : field.id %>
+ <%= form.label id, label %>
<% else %>
<%= field.name %>
<% end %> |
Describe the bug
When editing or creating new records with
belongs_to
fields label'sfor
value doesn't match the input'sid
value.In Chome inspector Issues tab the following messages appear:
Steps to Reproduce
has_many
/belongs_to
relationshipbelongs_to
fieldbelongs_to
belongs_to
fieldExpected behavior & Actual behavior
This config generates the following HTML:
You can see label's
for
isresult_event
but input'sid
isresult_event_id
.Expected to see the same id in label's
for
and in input'sid
.Models and resource files
System configuration
Avo version: 2.40.0
Rails version: 7.0.7.2
Ruby version: 3.2.2
License type:
Are you using Avo monkey patches, overriding views or view components?
Screenshots or screen recordings
N/A
Additional context
N/A
Impact
Urgency
The text was updated successfully, but these errors were encountered: