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/dropdown_field.rb,
lib/playbook/forms/builder/typeahead_field.rb,
lib/playbook/forms/builder/date_picker_field.rb,
lib/playbook/forms/builder/star_rating_field.rb,
lib/playbook/forms/builder/form_field_builder.rb,
lib/playbook/forms/builder/phone_number_field.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
- #dropdown_field(name, props: {}) ⇒ Object
- #intl_telephone(name, props: {}) ⇒ Object
- #multi_level_select(name, props: {}) ⇒ Object
- #phone_number_field(name, props: {}) ⇒ Object
- #select(name, choices = nil, options = {}, html_options = {}, props: {}, &block) ⇒ Object
- #star_rating_field(name, props: {}) ⇒ Object
- #typeahead(name, _options = {}, _html_options = {}, props: {}) ⇒ Object
Instance Method Details
#actions ⇒ Object
28 29 30 31 32 33 |
# File 'lib/playbook/forms/builder.rb', line 28 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 |
#dropdown_field(name, props: {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/playbook/forms/builder/dropdown_field.rb', line 6 def dropdown_field(name, props: {}) props[:name] = name props[:margin_bottom] = "sm" props[:label] = @template.label(@object_name, name) if props[:label] == true @template.pb_rails("dropdown", props: props) 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 |
#phone_number_field(name, props: {}) ⇒ Object
6 7 8 9 |
# File 'lib/playbook/forms/builder/phone_number_field.rb', line 6 def phone_number_field(name, props: {}) props[:name] = name @template.pb_rails("phone_number_input", 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 |
#star_rating_field(name, props: {}) ⇒ Object
6 7 8 9 10 11 |
# File 'lib/playbook/forms/builder/star_rating_field.rb', line 6 def (name, props: {}) props[:name] = name props[:margin_bottom] = "sm" props[:label] = @template.label(@object_name, name) if props[:label] == true @template.pb_rails("star_rating", props: props) 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 |