Module: SnippetCli::VarBuilder::FormFields

Defined in:
lib/snippet_cli/var_builder/form_fields.rb

Overview

Collects field-level configuration for form variable layouts.

Constant Summary collapse

FIELD_TYPES =
[
  'Single-line text box',
  'Multi-line text box',
  'Choice box',
  'List box'
].freeze

Class Method Summary collapse

Class Method Details

.collect(builder, layout) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/snippet_cli/var_builder/form_fields.rb', line 18

def self.collect(builder, layout)
  field_names = FormFieldParser.extract(layout)
  fields = {}
  field_names.each do |name|
    type = builder.prompt!(
      Gum.filter(*FIELD_TYPES, limit: 1, header: "[[#{name}]] field type")
    )
    config = field_config(builder, name, type)
    fields[name.to_sym] = config if config
  end
  fields
end