Sha256: 331937db0977d47118e3f326140f397e6c7f071119ffcf35785ca08267fe2721

Contents?: true

Size: 1.46 KB

Versions: 1

Compression:

Stored size: 1.46 KB

Contents

# frozen_string_literal: true

module Plutonium
  module UI
    module Form
      class Base < Phlexi::Form::Base
        include Plutonium::UI::Component::Behaviour

        class Builder < Builder
          include Plutonium::UI::Form::Options::InferredTypes

          def easymde_tag(**, &)
            create_component(Plutonium::UI::Form::Components::EasymdeInput, :easymde, **, &)
          end
          alias_method :markdown_tag, :easymde_tag

          alias_method :basic_select_tag, :select_tag
          def slim_select_tag(**, &)
            basic_select_tag(**, data_controller: "slim-select", class!: "", &)
          end
          alias_method :select_tag, :slim_select_tag

          def flatpickr_tag(**, &)
            create_component(Plutonium::UI::Form::Components::FlatpickrInput, :flatpickr, **, &)
          end
        end

        private

        def render_actions
          actions_wrapper {
            render submit_button
          }
        end

        def fields_wrapper(&)
          div(class: themed(:fields_wrapper, nil)) {
            yield
          }
        end

        def actions_wrapper(&)
          div(class: themed(:actions_wrapper, nil)) {
            yield
          }
        end

        def form_action
          return @form_action unless object.present? && @form_action != false && helpers.present?

          @form_action ||= url_for(object, action: object.new_record? ? :create : :update)
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
plutonium-0.15.23 lib/plutonium/ui/form/base.rb