Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

175
Views
Administrate gem — Pass custom HTML classes into fields

I use Rails 7, Ruby 2.7, the administrate gem for my admin dashboard and tailwindcss for the frontend.

I am trying to pass custom HTML classes into the fields. I have already generated the partials for all field types using the command rails generate administrate:views:field all.

For example, in app\views\fields\string\_form, how could I add to the input field a tailwind class? Below is a part of the generated file.

<div class="field-unit__field">
  <%= f.text_field field.attribute %>
</div>

The doc stipulates that there is an instance method called html_class inherited from Base but I struggle to apply it to the view.

Something like this would be perfect:

  • field.attribute.html_class("class1 class2 class3")
  • field.attribute.with_options(html_class: "class1 class2 class3")
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Woah ok, this was much easier than what I thought. I had to add the classes this way:

<div class="field-unit__field">
  <%= f.text_field field.attribute, class: "class1 class2 class3" %>
</div>
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!