Module: Faalis::Dashboard::Sections::ResourceCreate::ClassMethods
- Defined in:
- lib/faalis/dashboard/sections/resource_create.rb
Overview
The actual DSL for index ages
Instance Method Summary collapse
- #form_fields {|form| ... } ⇒ Object
-
#in_form(&block) ⇒ Object
To specify any property and action for ‘form` section both new and edit You must use `in_form` class method with block of properties.
-
#new_form_fields(*fields, **options) ⇒ Object
User can provides the fields that he/she wants to be shown in the form for resource creation page.
Instance Method Details
#form_fields {|form| ... } ⇒ Object
237 238 239 240 241 242 243 244 245 246 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 237 def form_fields form = ::Faalis::Dashboard::FormFieldsProperties.new yield form define_method(:_form_fields) do form end private :_form_fields end |
#in_form(&block) ⇒ Object
To specify any property and action for ‘form` section both new and edit You must use `in_form` class method with block of properties. For example:
class ExamplesController < Dashboard::Application
in_form do
attributes :name, :description
:close, dashboard_example_close_path
end
end
202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 202 def in_form(&block) model = model_class form_props = Faalis::Dashboard::DSL::Create.new(model) unless block_given? fail ArgumentError, "You have to provide a block for 'in_form'" end define_method(:form_properties) do unless defined? @__form_props__ instance_exec(form_props, &block) @__form_props__ = form_props end return @__form_props__ end private :form_properties end |
#new_form_fields(*fields, **options) ⇒ Object
User can provides the fields that he/she wants to be shown in the form for resource creation page. for example:
class Dashboard::PostsController < Dashboard::ApplicationController
new_form_fields :title, created_at
end
229 230 231 232 233 234 235 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 229 def new_form_fields(*fields, **) define_method(:_new_form_fields) do fields.map(&:to_sym) end private :_new_form_fields end |