ruby on rails - simple_form custom wrapper with a plain radio button -
i trying make custom wrapper hybrid form this:
the idea here there radio buttons enable either date picker, occurrences or indefinite. have these manually created , trying make custom simple form wrapper avoid hassle of adding tons of code simple input. second occurrence input 1 can't quite right. here html form shown:
<div class="form-group radio_buttons required work_order_end_task"> <label class="radio_buttons required col-sm-2 control-label"><i class="fa fa-check-circle text-danger"></i> end date</label> <div class="col-sm-2"> <div class="input-group"> <span class="input-group-addon border-none"> <input class="radio_buttons required" type="radio" value="date" name="work_order[end_task]" id="work_order_end_task_date"> </span> <input disabled="" type="text" value="" name="work_order[end_date]" id="work_order_end_date" data-provide="datepicker" data-date-format="yyyy-mm-dd" data-date-clear-btn="true" data-date-today-btn="linked" data-date-orientation="auto right" data-date-today-highlight="true" class="date required form-control left-border-rounded"> <span class="input-group-addon"> <i class="fa fa-calendar"></i> </span> </div> <br> <div class="input-group"> <span class="input-group-addon border-none"> <input class="radio_buttons required" type="radio" value="number" name="work_order[end_task]" id="work_order_end_task_number"> </span> <input class="numeric integer form-control" type="string" value="" name="work_order[count]" id="work_order_count"> <span class="input-group-addon"> occurrence(s) </span> </div> <br> <div class="input-group integer optional work_order_count"> <span class="input-group-addon border-none radio_buttons optional work_order_end_task"> <span class="radio"> <label for="work_order_end_task_none"> <input class="radio_buttons optional radio_buttons" type="radio" value="none" checked="checked" name="work_order[end_task]" id="work_order_end_task_none"> </label> </span> </span> <input class="string optional form-control" type="text" value="" name="work_order[count]" id="work_order_count"> <span class="input-group-addon">occurrence(s)</span> </div> <br> <div class="form-group radio_buttons optional work_order_end_task"><div class="col-sm-10"><span class="radio"><label class="static-radio" for="work_order_end_task_none"><input class="radio_buttons optional" type="radio" value="none" checked="checked" name="work_order[end_task]" id="work_order_end_task_none">indefinite</label></span></div></div> </div> </div>
the issue spans , labels being added. here code:
<%= f.input :count, wrapper: :input_group %> <%= f.input :end_task, as: :radio_buttons, wrapper: :radio_addon, collection: [['','none']], label: false %> <%= f.input_field :count, as: :string, class: "form-control" %> <span class="input-group-addon">occurrence(s)</span> <% end %>
and wrappers:
config.wrappers :input_group, tag: 'div', class: 'input-group', error_class: 'has-error' |b| b.use :html5 b.use :input, class: 'form-control' end config.wrappers :radio_addon, tag: 'span', class: 'input-group-addon border-none' |b| b.use :html5 b.optional :readonly b.use :input, class: 'radio_buttons' end
so how rid of <span class="radio">
, <label for="work_order_end_task_none">
on radio buttons , classes ( integer optional work_order_count
example) being inserted wrappers , inputs?
i think figured out (sort of):
<span class="input-group-addon border-none"> <%= f.radio_button :end_task, 'number', label: false %> </span>
works charm. still add custom wrapper avoid having manually add wrapper span not seem work.
Comments
Post a Comment