スポンサーリンク

Rails5.0でbootstrap-sassとsimple_form(3)

前回の続き。horizontal_formにしたい!

(参考)horizontal_form

http://techracho.bpsinc.jp/shibuya/2014_06_27/18101

 

config/initializers/simple_form_bootstrap.rbの139行目を、以下のように変更。(←下記の理由でうまくいかなかったので、結局もとに戻した。)

config.default_wrapper = :horizontal_form

(変更前)
image

(変更後)
image

rails s -b 0.0.0.0

localhost:3000/tasks/new

image

チェックボックスは、ずれている。

しかも、なぜか、Titleのところを編集することができなくなってしまった。理由は不明。

(参考)

http://www.ohmyenter.com/ruby-on-rails-bootstrap3-simple_form-%E3%83%81%E3%83%A5%E3%83%BC%E3%83%88%E3%83%AA%E3%82%A2%E3%83%AB/

https://github.com/rafaelfranca/simple_form-bootstrap/blob/master/app/views/examples/_horizontal_form_sf.html.erb

app/views/tasks/_form.html.erb の1行目を以下のように変更。

[sourcecode language=”ruby”]
<%= simple_form_for @task, html: { class: ‘form-horizontal’ },
wrapper: :horizontal_form,
wrapper_mappings: {
check_boxes: :horizontal_radio_and_checkboxes,
radio_buttons: :horizontal_radio_and_checkboxes,
file: :horizontal_file_input,
boolean: :horizontal_boolean
} do |f| %>
[/sourcecode]

(変更後)

image

localhost:3000/tasks/new を見ると、

image

やっと少しいい感じになってきた。

 

————————————

(参考)

http://ruby-rails.hatenadiary.com/entry/20140730/1406700205

rails generate migration AddRoomToTasks room:integer
rails db:migrate
rails generate migration AddBeginToTasks begin:date
rails db:migrate

tasksの、controller と、viewのindex, _form を適宜変更。

image

image

image

 

 

image

image

ラジオボタンが縦に並んでしまう。

日付がうまくいかない。

horizontal formはあきらめるか、それとも、simple_formは、やり方に苦慮すると、simple_formを使わないで、ふつうに記載した方が早いかもしれない。simple_formはあきらめるか。

———————————————–

image

image

いまいち、、、

image

スポンサーリンク