Class: Playbook::Forms::Builder
- Inherits:
-
ActionView::Helpers::FormBuilder
- Object
- ActionView::Helpers::FormBuilder
- Playbook::Forms::Builder
- Defined in:
- lib/playbook/forms/builder.rb,
lib/playbook/forms/builder/action_area.rb,
lib/playbook/forms/builder/select_field.rb,
lib/playbook/forms/builder/checkbox_field.rb,
lib/playbook/forms/builder/typeahead_field.rb,
lib/playbook/forms/builder/date_picker_field.rb,
lib/playbook/forms/builder/form_field_builder.rb,
lib/playbook/forms/builder/intl_telephone_field.rb,
lib/playbook/forms/builder/collection_select_field.rb,
lib/playbook/forms/builder/multi_level_select_field.rb
Defined Under Namespace
Classes: ActionArea, FormFieldBuilder
Instance Method Summary collapse
- #actions ⇒ Object
- #check_box(name, props: {}, **options) ⇒ Object
- #collection_select(name, collection, value_method, text_method, options = {}, html_options = {}, props: {}) ⇒ Object
- #date_picker(name, props: {}) ⇒ Object
- #intl_telephone(name, props: {}) ⇒ Object
- #multi_level_select(name, props: {}) ⇒ Object
- #select(name, choices = nil, options = {}, html_options = {}, props: {}, &block) ⇒ Object
- #typeahead(name, _options = {}, _html_options = {}, props: {}) ⇒ Object
Instance Method Details
#actions ⇒ Object
25 26 27 28 29 30 |
# File 'lib/playbook/forms/builder.rb', line 25 def actions context = @template.respond_to?(:view_context) ? @template.view_context : @template context.content_tag :ol, class: "pb-form-actions" do yield ActionArea.new(@template, submit_default_value) end end |
#check_box(name, props: {}, **options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/playbook/forms/builder/checkbox_field.rb', line 6 def check_box(name, props: {}, **) label_text = @template.label(@object_name, name) if props[:label] == true [:required] = true if props[:required] props[:margin_bottom] = "sm" props[:form_spacing] = true checked_value = [:checked_value] unchecked_value = [:unchecked_value] .delete(:checked_value) .delete(:unchecked_value) input = super(name, , checked_value, unchecked_value) if props[:label] @template.pb_rails("caption", props: { text: label_text, margin_bottom: "xs" }) + @template.pb_rails("checkbox", props: props) do input end else @template.pb_rails("checkbox", props: props) do input end end end |
#collection_select(name, collection, value_method, text_method, options = {}, html_options = {}, props: {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/playbook/forms/builder/collection_select_field.rb', line 6 def collection_select(name, collection, value_method, text_method, = {}, = {}, props: {}) props[:label] = @template.label(@object_name, name) if props[:label] == true [:skip_default_ids] = false unless .key?(:skip_default_ids) [:prompt] = props[:blank_selection] || "" [:required] = "required" if props[:required] input = super(name, collection, value_method, text_method, , ) @template.pb_rails("select", props: props) do input end end |
#date_picker(name, props: {}) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/playbook/forms/builder/date_picker_field.rb', line 6 def date_picker(name, props: {}) prefix = @object_name html_attribute_name = "#{prefix}[#{name}]" html_id = "#{prefix}_#{name}" props[:label] = @template.label(@object_name, name) if props[:label] == true props[:label] = "Date Picker" if props[:label].nil? props[:name] = html_attribute_name props[:picker_id] = html_id input = text_field( name, autocomplete: "off", disabled: props[:disable_input], data: props[:input_data], aria: props[:input_aria], props: { error: props[:error], label: props[:hide_label] ? nil : props[:label], placeholder: props[:placeholder], required: props[:required], } ) @template.pb_rails("date_picker", props: props) do input end end |
#intl_telephone(name, props: {}) ⇒ Object
6 7 8 9 |
# File 'lib/playbook/forms/builder/intl_telephone_field.rb', line 6 def intl_telephone(name, props: {}) props[:name] = name @template.pb_rails("phone_number_input", props: props) end |
#multi_level_select(name, props: {}) ⇒ Object
6 7 8 9 |
# File 'lib/playbook/forms/builder/multi_level_select_field.rb', line 6 def multi_level_select(name, props: {}) props[:name] = name @template.pb_rails("multi_level_select", props: props) end |
#select(name, choices = nil, options = {}, html_options = {}, props: {}, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/playbook/forms/builder/select_field.rb', line 6 def select(name, choices = nil, = {}, = {}, props: {}, &block) props[:label] = @template.label(@object_name, name) if props[:label] == true [:skip_default_ids] = false unless .key?(:skip_default_ids) [:prompt] = props[:blank_selection] || "" [:required] = "required" if props[:required] input = super(name, choices, , , &block) @template.pb_rails("select", props: props) do input end end |
#typeahead(name, _options = {}, _html_options = {}, props: {}) ⇒ Object
6 7 8 9 |
# File 'lib/playbook/forms/builder/typeahead_field.rb', line 6 def typeahead(name, = {}, = {}, props: {}) props[:name] = name @template.pb_rails("typeahead", props: props) end |