class ActiveDryForm::Builder
Public Instance Methods
fields_for(record_name, &block)
click to toggle source
Calls superclass method
# File lib/active_dry_form/builder.rb, line 72 def fields_for(record_name, &block) super(@object.send(record_name), &block) end
input(method, options = {})
click to toggle source
# File lib/active_dry_form/builder.rb, line 6 def input(method, options = {}) dry_tag = ActiveDryForm::Input.new(self, __method__, method, options) input_tag = case dry_tag.input_type when 'date' then text_field(method, dry_tag.input_opts.merge('data-controller': 'flatpickr')) when 'date_time' then text_field(method, dry_tag.input_opts.merge('data-controller': 'flatpickr', 'data-flatpickr-enable-time': 'true')) when 'integer' then number_field(method, dry_tag.input_opts) when 'bool' then check_box(method, dry_tag.input_opts) else case method.to_s when /password/ then password_field(method, dry_tag.input_opts) when /email/ then email_field(method, dry_tag.input_opts) when /phone/ then telephone_field(method, dry_tag.input_opts) when /url/ then url_field(method, dry_tag.input_opts) else text_field(method, dry_tag.input_opts) end end dry_tag.wrap_tag input_tag end
input_checkbox_inline(method, options = {})
click to toggle source
# File lib/active_dry_form/builder.rb, line 33 def input_checkbox_inline(method, options = {}) dry_tag = ActiveDryForm::Input.new(self, __method__, method, options) dry_tag.wrap_tag check_box(method, dry_tag.input_opts), label_last: true end
input_file(method, options = {})
click to toggle source
# File lib/active_dry_form/builder.rb, line 43 def input_file(method, options = {}) dry_tag = ActiveDryForm::Input.new(self, __method__, method, options) dry_tag.wrap_tag file_field(method, dry_tag.input_opts) end
input_select(method, collection, options = {}, html_options = {})
click to toggle source
# File lib/active_dry_form/builder.rb, line 28 def input_select(method, collection, options = {}, html_options = {}) # rubocop:disable Gp/OptArgParameters dry_tag = ActiveDryForm::Input.new(self, __method__, method, options) dry_tag.wrap_tag select(method, collection, dry_tag.input_opts, html_options) end
input_text(method, options = {})
click to toggle source
# File lib/active_dry_form/builder.rb, line 38 def input_text(method, options = {}) dry_tag = ActiveDryForm::Input.new(self, __method__, method, options) dry_tag.wrap_tag text_area(method, dry_tag.input_opts) end
show_base_errors()
click to toggle source
# File lib/active_dry_form/builder.rb, line 52 def show_base_errors return unless @object.base_errors tag.div class: 'callout alert' do tag.ul do # внутри ошибки может быть html @object.base_errors.map { tag.li _1.html_safe }.join.html_safe end end end
show_error(method)
click to toggle source
# File lib/active_dry_form/builder.rb, line 63 def show_error(method) ActiveDryForm::Input.new(self, __method__, method, {}).error_text end