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
227 228 229 230 231 232 233 234 235 236 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 227 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
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 192 def in_form(&block) model = controller_name.classify.constantize 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
219 220 221 222 223 224 225 |
# File 'lib/faalis/dashboard/sections/resource_create.rb', line 219 def new_form_fields(*fields, **) define_method(:_new_form_fields) do fields.map(&:to_sym) end private :_new_form_fields end |