DelGiudice
DelGiudice

Reputation: 1867

How to render custom form fields on rails

So by default RoR has Form Helpers that let you render form fields easily eg

<% form_for @article do |f| %>
  <%= f.text_field :name %>
<% end %>

Awesome but let's say i want to render all my forms in a different way let's say i want to add different things

  1. Bootstrap classes to fields form-control
  2. Red asterisk next to the label if it's required.
  3. data-toggle="validator"

Just to name a few, What would be the best way i can achieve these?

Upvotes: 1

Views: 1038

Answers (1)

Dharam Gollapudi
Dharam Gollapudi

Reputation: 6438

You can achieve this by defining your own custom form builder.

Refer to Form Builder for more info.

Upvotes: 1

Related Questions