0

Mongoid 2.0 用のフォームビルダーはありますか? モデルからフォームを自動的に生成します。

ありがとう

4

2 に答える 2

0

https://github.com/mcasimir/document_form

gem document_form

これは、私が作成したhttps://github.com/justinfrench/formtasticからのフォークで、Mongoid 2 に移動したばかりです。

モデル

  class Person
    include Mongoid::Document
    include Mongoid::MultiParameterAttributes

    validates_presence_of :name

    field :name
    field :secret,            :private => true
    field :birthday,          :type => Date
    field :department_number, :type => Integer, :range => 1..10

    field :description,       :long => true
  end

意見

    <% document_form_for @object do |f| %>
      <%= f.inputs %>
      <%= f.buttons %>
    <% end %>

これは基本的な例です。ここでは、フォーム ビルダーは、宣言されているのと同じ順序でフィールドをレンダリングし、:private => true.

急いでおらず、より柔軟なものが必要な場合は、次のように、formtastic と同じ構文を使用してフィールド広告オプションをいつでも指定できます。

  <% f.inputs do %>
    <%= f.input :title %>
    <%= f.input :published, :label => "This post is published" %>
    <%= f.input :section_id %>
    <%= f.input :image_filename, :hint => "540x300" %>
  <% end %>

あなたがそれを試してみることに決めたら、私はあらゆる種類のフィードバックに感謝します.

于 2011-12-04T19:02:45.100 に答える
0

Rails のサッカーフォールディングを使用しないのはなぜですか?

于 2011-10-02T14:08:28.803 に答える