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.
359 360 361 |
# File 'lib/admin/base/resource.rb', line 359 def initialize @fields_list = [] end |
Instance Attribute Details
#fields_list ⇒ Object (readonly)
Returns the value of attribute fields_list.
357 358 359 |
# File 'lib/admin/base/resource.rb', line 357 def fields_list @fields_list end |
Instance Method Details
#field(name, **options) ⇒ Object
363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 |
# File 'lib/admin/base/resource.rb', line 363 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] ) end |
#row(**options, &block) ⇒ Object
398 399 400 401 402 |
# File 'lib/admin/base/resource.rb', line 398 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
387 388 389 390 391 392 393 394 395 396 |
# File 'lib/admin/base/resource.rb', line 387 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 |