Class: Admin::Base::Resource::FormConfig
- Inherits:
-
Object
- Object
- Admin::Base::Resource::FormConfig
- Defined in:
- lib/admin/base/resource.rb
Instance Attribute Summary collapse
-
#fields_list ⇒ Object
readonly
Returns the value of attribute fields_list.
Instance Method Summary collapse
- #field(name, **options) ⇒ Object
-
#initialize ⇒ FormConfig
constructor
A new instance of FormConfig.
- #row(**options, &block) ⇒ Object
- #section(title, **options, &block) ⇒ Object
Constructor Details
#initialize ⇒ FormConfig
Returns a new instance of FormConfig.
390 391 392 |
# File 'lib/admin/base/resource.rb', line 390 def initialize @fields_list = [] end |
Instance Attribute Details
#fields_list ⇒ Object (readonly)
Returns the value of attribute fields_list.
388 389 390 |
# File 'lib/admin/base/resource.rb', line 388 def fields_list @fields_list end |
Instance Method Details
#field(name, **options) ⇒ Object
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 |
# File 'lib/admin/base/resource.rb', line 394 def field(name, **) @fields_list << FieldDefinition.new( name: name, type: [:type] || :text, required: [:required] || false, label: [:label] || name.to_s.humanize, help: [:help], placeholder: [:placeholder], collection: [:collection], create_url: [:create_url], accept: [:accept], rows: [:rows], readonly: [:readonly] || false, if_condition: [:if], unless_condition: [:unless], multiple: [:multiple] || false, creatable: [:creatable] || false, preview: [:preview] != false, variants: [:variants], label_color: [:label_color], label_size: [:label_size], parent_field: [:parent_field] ) end |
#row(**options, &block) ⇒ Object
430 431 432 433 434 |
# File 'lib/admin/base/resource.rb', line 430 def row(**, &block) @fields_list << RowDefinition.new(cols: [:cols] || 2) instance_eval(&block) if block_given? @fields_list << RowEnd.new end |
#section(title, **options, &block) ⇒ Object
419 420 421 422 423 424 425 426 427 428 |
# File 'lib/admin/base/resource.rb', line 419 def section(title, **, &block) @fields_list << SectionDefinition.new( title: title, description: [:description], collapsible: [:collapsible] || false, collapsed: [:collapsed] || false ) instance_eval(&block) if block_given? @fields_list << SectionEnd.new end |