Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

177
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda