Jérémy Pouyet
Jérémy Pouyet

Reputation: 2019

rails : generate a form with simple_form without the design

Is there a way to generate a form with simple_form without generate the design ?

I would like to pass from this :

<form accept-charset="UTF-8" action="/users" data-remote="true" id="new_user" method="post" novalidate="novalidate">
  <div class="control-group string required user_email">
    <div class="controls">
      <input class="string required" id="user_email" name="user[email]" size="50" type="text">
    </div>
  </div>
</form>

to this :

<form accept-charset="UTF-8" action="/users" data-remote="true" id="new_user" method="post" novalidate="novalidate">
  <input class="string required" id="user_email" name="user[email]" size="50" type="text">
</form>

Upvotes: 0

Views: 128

Answers (1)

vee
vee

Reputation: 38645

Yes it is possible. Take a read on "Stripping away all wrapper divs" from the simple form's documentation.

Using f.input_field inplace of f.input is going to not include the wrapper divs which you want to get rid of.

Example from the doc:

simple_form_for @user do |f|
  f.input_field :name
  f.input_field :remember_me, as: :boolean
end

generates:

<form>
  ...
  <input class="string required" id="user_name" maxlength="255" name="user[name]" size="255" type="text">
  <input name="user[remember_me]" type="hidden" value="0">
  <label class="checkbox">
    <input class="boolean optional" id="user_published" name="user[remember_me]" type="checkbox" value="1">
  </label>
</form>

Upvotes: 2

Related Questions