如果I read right,如果我的属性类型为:date
或:text
,则simple_form
应默认显示 a { {1}}和date select
输入。
据我所知,情况并非如此。
以下是有关的迁移,这是最后一次:
textarea
表单的代码:
class CompleteGroupActionsTable < ActiveRecord::Migration
def change
add_column :group_actions, :concerned_object, :string, null: false, default: ""
add_column :group_actions, :concerned_company, :string, null: false, default: ""
add_column :group_actions, :date, :date, null: false
add_column :group_actions, :amount_estimation, :string, null: false, default: ""
add_column :group_actions, :description, :text, null: false, default: ""
add_column :group_actions, :tags, :string
end
end
生成的HTML:
section
.row
h1= t('actions.new')
.row
= simple_form_for :group_action, url: admin_actions_path do |f|
= f.input :concerned_object
= f.input :concerned_company
= f.input :date
= f.input :amount_estimation
= f.input :description
= f.input :tags
= f.button :submit
运行迁移时没有错误。我不想硬设置输入类型,否则我会使用<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<section>
<div class="row">
<h1>Nouvelle action</h1>
</div>
<div class="row">
<form accept-charset="UTF-8" action="/admin/actions" class=
"simple_form group_action" method="post" novalidate="novalidate">
<div style="display:none">
<input name="utf8" type="hidden" value="✓"><input name=
"authenticity_token" type="hidden" value=
"d24b3skP/N3Dr94Udvny2Hzi9fZkWfHhEYArm09R8wo=">
</div>
<div class=
"input string required group_action_concerned_object">
<label class="string required control-label" for=
"group_action_concerned_object"><abbr title=
"required">*</abbr> Produit ou Service
concerné</label><input class="string required" id=
"group_action_concerned_object" name=
"group_action[concerned_object]" style=
"background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABHklEQVQ4EaVTO26DQBD1ohQWaS2lg9JybZ+AK7hNwx2oIoVf4UPQ0Lj1FdKktevIpel8AKNUkDcWMxpgSaIEaTVv3sx7uztiTdu2s/98DywOw3Dued4Who/M2aIx5lZV1aEsy0+qiwHELyi+Ytl0PQ69SxAxkWIA4RMRTdNsKE59juMcuZd6xIAFeZ6fGCdJ8kY4y7KAuTRNGd7jyEBXsdOPE3a0QGPsniOnnYMO67LgSQN9T41F2QGrQRRFCwyzoIF2qyBuKKbcOgPXdVeY9rMWgNsjf9ccYesJhk3f5dYT1HX9gR0LLQR30TnjkUEcx2uIuS4RnI+aj6sJR0AM8AaumPaM/rRehyWhXqbFAA9kh3/8/NvHxAYGAsZ/il8IalkCLBfNVAAAAABJRU5ErkJggg==); background-attachment: scroll; background-position: 100% 50%; background-repeat: no-repeat;"
type="text">
</div>
<div class=
"input string required group_action_concerned_company">
<label class="string required control-label" for=
"group_action_concerned_company"><abbr title=
"required">*</abbr> Société concernée</label><input class=
"string required" id="group_action_concerned_company" name=
"group_action[concerned_company]" type="text">
</div>
<div class="input string required group_action_date">
<label class="string required control-label" for=
"group_action_date"><abbr title="required">*</abbr> Date
des faits</label><input class="string required" id=
"group_action_date" name="group_action[date]" type="text">
</div>
<div class=
"input string required group_action_amount_estimation">
<label class="string required control-label" for=
"group_action_amount_estimation"><abbr title=
"required">*</abbr> Estimation du montant du
préjudice</label><input class="string required" id=
"group_action_amount_estimation" name=
"group_action[amount_estimation]" type="text">
</div>
<div class="input string required group_action_description">
<label class="string required control-label" for=
"group_action_description"><abbr title="required">*</abbr>
Description du problème</label><input class=
"string required" id="group_action_description" name=
"group_action[description]" type="text">
</div>
<div class="input string required group_action_tags">
<label class="string required control-label" for=
"group_action_tags"><abbr title="required">*</abbr>
Mots-clés / Tags</label><input class="string required" id=
"group_action_tags" name="group_action[tags]" type="text">
</div><input class="button" name="commit" type="submit" value=
"Submit Group action">
</form>
</div>
</section>
</body>
</html>
失去一些好处。
simple_form
我错过了什么?
答案 0 :(得分:0)
您需要将对象传递给simple_form_for帮助程序,而不是符号。
= simple_form_for @group_action, url: admin_actions_path do |f|