如何使文本字段仅接受数值?如果我按下字母或符号,则不应填写文本字段,只应允许数字.
有没有铁路方式来做到这一点?
是否有可能为Rails 3中的time_zone_select FormHelper提供一个CSS类.我目前有类似的东西
f.time_zone_select :time_zone
Run Code Online (Sandbox Code Playgroud)
尝试了类似的选项 -
f.time_zone_select:time_zone,nil,:class =>'classname'
但这不起作用
我有一个来自devise的rails helper文本字段,它使用html并自动验证type="email"字段.我想要添加属性novalidate='novalidate',但我不知道如何..继承人代码..任何建议?
<%= form_for(resource, :as => resource_name, :url => session_path(resource_name)
) do |f| %>
<p><%= f.label :login %><br />
<%= f.email_field :login %></p>
Run Code Online (Sandbox Code Playgroud) 我有一个名为Category和其他模型产品的模型.他们有has_many和belongs_to关系.但在我看来代码
<p><%= f.collection_select(:product, :category_id, Category.all, :id, :name)%>
Run Code Online (Sandbox Code Playgroud)
给了我
undefined method `merge' for :name:Symbol
Run Code Online (Sandbox Code Playgroud)
有什么线索有什么问题吗?
我正在使用SimpleForm来构建我的表单.
我说的是以下型号:
class ScheduledContent < ActiveRecord::Base
belongs_to :parent
attr_accessible :lots, :of, :other, :fields
serialize :schedule, Array
end
Run Code Online (Sandbox Code Playgroud)
我想构建一个表单,其中包含许多其他字段和关联(此模型实际上已经是has_many关联的一部分 - 所以非常复杂的形式)用户被呈现可变天数(例如第1天,第2天,第3天等) - 每天都可以选中或取消选中.因此,如果用户检查第1天,第5天说 - 我想在计划字段中存储[1,5].在表单之前 - 我可以构建一个可供选择的简单数组,包括显然已经选择的日期.
使用SimpleForm的表单助手表示此表单的最佳方法是什么?如果不可能这样做 - 我也可以使用Rails的表单助手来使其工作,但我的偏好是SimpleForm,因为表单的其余部分已经使用SimpleForm构建.
我的表单中有一个text_field_tag,我真的希望它只是用于显示(我的所有jquery更新此文本字段),使用日期选择器.虽然我不希望用户在这里输入,所以我说:disabled => true并确定它被禁用,值在这里改变但是在我的ajax远程调用中他们不保存,只有当text_field_tag被启用时才会保存.这有什么工作吗?
此代码:= form_fo:store_products do | f | = f.check_box:track_inventory
创建这个HTML:
<input name="product_group[products_attributes][0][store_products_attributes}[1342647745501][track_inventory]" type="hidden" value="0">
<input id="product_group_products_attributes_0_store_products_attributes_1342647745501_track_inventory" name="product_group[products_attributes][0][store_products_attributes][1342647745501][track_inventory]" type="checkbox" value="1">
Run Code Online (Sandbox Code Playgroud)
第一个隐藏元素的原因是什么?
Twitter Bootstrap具有表单的此角色属性:
<form role="form">
Run Code Online (Sandbox Code Playgroud)
如何在Rails表单助手中包含角色属性?我试过这个,但它不起作用:
<%= form_for @user, class: "form-horizontal", role: "form" do |f| %>
Run Code Online (Sandbox Code Playgroud) 如何在CakePHP 3.0.0中更改输入包装器div类.
我的代码是:
<?= $this->Form->input('mobile',['div'=>['class'=>'col-md-4'],'class'=>'form-control','label'=>false]) ?>
Run Code Online (Sandbox Code Playgroud)
它返回:
<div class="input text">
<input type="text" name="mobile" div="col-md-4" class="form-control" id="mobile">
</div>
Run Code Online (Sandbox Code Playgroud)
我想输出像:
<div class="col-md-4">
<input type="text" name="mobile" class="form-control" id="mobile">
</div>
Run Code Online (Sandbox Code Playgroud) Rails生成一个表单partial,可以在get动作呈现的页面和新动作呈现的页面上使用.如果是前者,则将表单的方法设置为PUT,如果是后者,则将表单的操作设置为POST.
rails如何决定使用哪种方法?
form-helpers ×10
forms ×2
cakephp ×1
cakephp-3.0 ×1
jquery ×1
rest ×1
role ×1
ruby-1.9.2 ×1
simple-form ×1
textfield ×1
validation ×1