Class: Playbook::PbForm::FormBuilder::FormFieldBuilder
- Inherits:
-
Module
- Object
- Module
- Playbook::PbForm::FormBuilder::FormFieldBuilder
- Defined in:
- app/pb_kits/playbook/pb_form/form_builder/form_field_builder.rb
Instance Method Summary collapse
-
#initialize(method_name, kit_name:) ⇒ FormFieldBuilder
constructor
A new instance of FormFieldBuilder.
Constructor Details
#initialize(method_name, kit_name:) ⇒ FormFieldBuilder
Returns a new instance of FormFieldBuilder.
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'app/pb_kits/playbook/pb_form/form_builder/form_field_builder.rb', line 7 def initialize(method_name, kit_name:) define_method method_name do |name, props: {}, **, &block| props[:label] = @template.label(@object_name, name) if props[:label] == true = Hash() [:skip_default_ids] = false unless .key?(:skip_default_ids) [:required] = true if props[:required] [:placeholder] = props[:placeholder] || "" if props.key?(:validation) validation = props[:validation] [:pattern] = validation[:pattern] if validation[:pattern].present? [:data] = { message: validation[:message] } if validation[:message].present? end input = super(name, **, &block) @template.pb_rails(kit_name, props: props) do input end end end |