class Playbook::Forms::Builder
def actions
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
def check_box(name, props: {}, **options)
def check_box(name, props: {}, **options) label_text = @template.label(@object_name, name) if props[:label] == true options[:required] = true if props[:required] props[:margin_bottom] = "sm" props[:form_spacing] = true checked_value = options[:checked_value] unchecked_value = options[:unchecked_value] options.delete(:checked_value) options.delete(:unchecked_value) input = super(name, options, 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
def collection_select(name, collection, value_method, text_method, options = {}, html_options = {}, props: {})
def collection_select(name, collection, value_method, text_method, options = {}, html_options = {}, props: {}) props[:label] = @template.label(@object_name, name) if props[:label] == true options[:skip_default_ids] = false unless options.key?(:skip_default_ids) options[:prompt] = props[:blank_selection] || "" html_options[:required] = "required" if props[:required] input = super(name, collection, value_method, text_method, options, html_options) @template.pb_rails("select", props: props) do input end end
def date_picker(name, props: {})
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
def dropdown_field(name, props: {})
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
def intl_telephone(name, props: {})
def intl_telephone(name, props: {}) props[:name] = name @template.pb_rails("phone_number_input", props: props) end
def multi_level_select(name, props: {})
def multi_level_select(name, props: {}) props[:name] = name @template.pb_rails("multi_level_select", props: props) end
def phone_number_field(name, props: {})
def phone_number_field(name, props: {}) props[:name] = name @template.pb_rails("phone_number_input", props: props) end
def select(name, choices = nil, options = {}, html_options = {}, props: {}, &block)
def select(name, choices = nil, options = {}, html_options = {}, props: {}, &block) props[:label] = @template.label(@object_name, name) if props[:label] == true options[:skip_default_ids] = false unless options.key?(:skip_default_ids) options[:prompt] = props[:blank_selection] || "" html_options[:required] = "required" if props[:required] input = super(name, choices, options, html_options, &block) @template.pb_rails("select", props: props) do input end end
def star_rating_field(name, props: {})
def star_rating_field(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
def typeahead(name, _options = {}, _html_options = {}, props: {})
def typeahead(name, _options = {}, _html_options = {}, props: {}) props[:name] = name @template.pb_rails("typeahead", props: props) end