I have a rails app with the “simpleform” and “bootstrap-datepicker-rails” gems.
I try to make the view code more readable like this:
f.input :birthday, :mydatefield, :options => {:icon => "calendar", :data-date => "21.12.2012", :data-format => "dd-mm-yyyy"}
At this moment I write this:
<div class="input-append date" id="user_birthday" data-date="12-02-2012" data-date-format="dd-mm-yyyy">
<%= f.input_field :birthday, :disabled => true %>
<span class="add-on">
<i class="icon-calendar"></i>
</span>
</div>
or this
<%= f.input :birthday, :wrapper => :datepicker, :wrapper_html=> {id: "user-birthday", class: "date"} do %>
<%= f.input_field :birthday, :disabled => true %>
<%= content_tag :span, :class => "add-on" do %>
<%= content_tag :i, :style => "color:grey", :class => "icon-calendar" do
end %>
<% end %>
<% end %>
to get my result:

Both of above are making this result, which works well:
<div class="control-group string required date" id="user-birthday">
<label class="string required control-label" for="user_birthday"><abbr title="required">*</abbr> Birthday</label>
<div class="controls">
<div class="input-append">
<input class="string required disabled" disabled="disabled" id="user_birthday" name="user[birthday]" size="50" type="text" />
<span class="add-on">
<i class="icon-calendar" style="color:grey"></i>
</span>
</div>
</div>
</div>
When I try to parse variables to the wrapper
:wrapper_html=> => {:data-date => "21-12-2012"}
it throw errors…
What I have to do? I am quite new on extending gems.
What I have to write to get this working?
- SimpleForm Wrapper?
- app/inputs/datepickerInput.rb?
- initializer/datepicker.rb?
- Helper Method?
An example will be VERY helpful!
Many thanks in advance!
I have switched back to the rails implemented forms. For me (as a beginner) simple_form seems not to be clear enough.
For my solution above I created a FormBuilder:
Thanks for your help!