ear*_*old 3 ruby-on-rails rails-admin
我觉得这应该是显而易见的,但我在文档中找不到它.
我正在使用rails_admin构建一个简单的CMS.
考虑一下:
config.model Article do
list do
field :title
field :created_at
field :updated_at
end
edit do
field :title
field :description do
required true #this line is pseudo code! What is the real thing?
maxlength 600 #ditto this line
end
end
end
Run Code Online (Sandbox Code Playgroud)
如何将这两行伪代码转换为"required"和"maxlength"的实际标记?
为了获得所需的输出,您的配置应该是:
config.model Article do
list do
field :title
field :created_at
field :updated_at
end
edit do
field :title
field :description, :string do #use second parameter to set field type
required true #this will just set a hints text
#to set max length use:
html_attributes do
{:maxlength => 600} #dont use 600 as maxlength for a string field. It will break the UI
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3807 次 |
| 最近记录: |