Question

I feel like this should be obvious, but I just cannot find it in the documentation.

I am using rails_admin to build a simple CMS.

Consider this:

 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

How do I turn those two lines of pseudo-code into real marks of "required" and "maxlength"?

Was it helpful?

Solution

To get you desired output your configuration should like:

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top