-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
belongs_to with class_name not working #323
Comments
Hey, @michaelimstepf! In headquarters: Field::BelongsTo to: headquarters: Field::BelongsTo.with_options(class_name: "Location") Let me know if that solves your problem. |
@Graysonwright Awesome, thanks, that worked. Another question that I couldn't find an answer for in the documentation. |
@michaelimstepf what version of Administrate are you using? I think we may have fixed the As for the |
@Graysonwright You're a legend, upgrading from 0.1.1 to 0.1.2 fixed both issues. Is there any way I can pass in an HTML class to a field? I saw in the Ruby docs that there's an html_class method but it doesn't accept any argument. I'm basically trying to add some custom styling (I have a verified checkbox/boolean for some attributes that I want to float left to the field it applies to). |
@michaelimstepf The The best way to do that right now would be to generate the view and override the HTML. I think we could add better support for this by accepting a name: Field::String.with_options(html_class: "username") If we take that approach, the question comes up of how this is handled on the different pages. Would we apply the html class to the form as well as the table cell, or would we allow users to pass in different classes for each of the pages? Another option would be to add another HTML class by default to all of the fields, with the format What are your thoughts on those options? |
@Graysonwright Thx. They syntax you posted looks very good to me. Given that all three pages (index, show, edit) use different html attributes, I would just apply the same class to all of the three pages and then it's up to the user to limit the scope to a specific html element. The other option you suggested (HTML class by default to all of the fields) would work but I think is inferior for the following reasons: It's less DRY, in your CSS you'll maintain a list of attributes for a specific style as opposed to just using one single class: .some-class {}
.attribute-name, .attribute-gender, .attribute-nationality {} And also, even though it's a class, it behaves more like an id, which is a bit confusing. Then lastly, for me it would be very useful to have the class being applied to the wrapping element:
The reason for this request is that for my use case I actually want to have certain related form fields floating next to each other. It's always easy to target a child within a class for those who want to only style an input or label tag but with pure CSS there's no sane way to target a parent element if the CSS is being applied to the input field for instance. |
We've gotten a bit off-topic, and I think it would be good to move this into its own issue. I'm going to close this and add another issue for it. |
Moved to #351. |
I have the following column and relationship, which works fine in AR:
When editing an
Organization
record, I get the attached error. How can I fix this? ThxThe text was updated successfully, but these errors were encountered: