在simple_form horizo​​ntal-form中创建提示span包装div?

时间:2015-03-07 20:27:20

标签: ruby-on-rails simple-form

当在simple_form 3中使用水平形式时,我有一个f.input :name, hint: "this is a really long hint"提示将显示在输入字段下并包装到输入被约束到的任何宽度。

enter image description here

如何在标签和输入下进行提示显示,但仍然在标签和输入周围的表格组div中?

这是我的一个字段当前呈现的方式(如上面的屏幕截图所示):

<div class="form-group string optional scenario_answers_value">
  <label class="string optional col-xs-8 control-label" for="scenario_answers_attributes_14_value">Customer's Normal Oil Change Interval</label>
  <div class="col-xs-4">
    <input class="string optional form-control" data-original-title="hrs" data-placement="bottom" data-toggle="tooltip" data-trigger="focus" id="scenario_answers_attributes_14_value" name="scenario[answers_attributes][14][value]" rel="tooltip" type="text">
    <p class="help-block">Most LT manufacturers recommend 250 hours because of wet stacking problems from the engine not running under a load.</p>
  </div>
</div>

1 个答案:

答案 0 :(得分:1)

您强制使用引导网格渲染表单组。标签的8/12行和输入字段的4/12。这样,您就不能使用提示了。 你需要这样的东西:

`

<div class='form-group'> 
  <div class='row'>
    <div class='col-xs-8'>
      <label>
    </div>
    <div class='col-xs-4'>
      <input class='form-control'>
    </div>
  </div>
  <div class='row'>
    <div class='col-xs-12'>
     <p class='hint'></p>
    </div>
  </div>
</div>

或者您可以尝试使用CSS设置提示,但这不是最好的方法。 此外,您可以提供erb \ haml \ slim标记以获得更有用的答案。

相关问题