Simple_form: Remove outer label for an inline checkbox with label

前端 未结 6 1483
盖世英雄少女心
盖世英雄少女心 2021-02-02 07:14

Using Simple_form 2.0.2

The simple form code using HAML:

= f.input :remember_me, as: :boolean, inline_label: \'Remember me\'

But it ren

6条回答
  •  长发绾君心
    2021-02-02 07:51

    With simple_form 2.1.0 and rails 3.0.20, none of the solutions listed here worked (I don't want to use f.input_field because it's an admission of defeat).

    The missing part is the boolean_style option:

    options.merge!({label: false, boolean_style: :inline})
    

    I suggest you create a custom input for this (e.g.: inline_checkbox)

    boolean_style is configured as :nested by default, I think:

    # Defaults to :nested for bootstrap config.
    #   :inline => input + label
    #   :nested => label > input
    config.boolean_style = :nested
    

提交回复
热议问题