Class: Ui::SearchForm

Inherits:
Components::ApplicationComponent
  • Object
show all
Includes:
Phlex::Rails::Helpers::FormWith, Phlex::Rails::Helpers::Request
Defined in:
app/views/rails_devtools/components/ui/search_form.rb

Instance Method Summary collapse

Constructor Details

#initialize(form:, path:, method:) ⇒ SearchForm

Returns a new instance of SearchForm.



9
10
11
12
13
# File 'app/views/rails_devtools/components/ui/search_form.rb', line 9

def initialize(form:, path:, method:)
  @form = form
  @path = path
  @method = method
end

Instance Method Details

#view_templateObject



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/views/rails_devtools/components/ui/search_form.rb', line 15

def view_template
  div(class: "flex gap-2 mt-4") do
    form_with(
      model: @form,
      url: @path,
      method: @method,
      data: { turbo_action: :advance },
      class: "w-full max-w-sm"
    ) do |form|
      label(class: "input input-bordered flex items-center gap-2 w-full grow") do
        form.text_field(:search,
                        { class: " w-full ", placeholder: "Type search then enter", value: search_params })
        search_icon
      end
    end

    reset_button if search_params.present?
  end
end