baoagency / polaris_view_components

ViewComponents for Polaris Design System
https://polarisviewcomponents.org
MIT License
388 stars 54 forks source link

Feature: add autocomplete to form builder #408

Closed k0va1 closed 7 months ago

k0va1 commented 7 months ago
<%= form_with(model: product, builder: Polaris::FormBuilder) do |form| %>
  <%= form.polaris_autocomplete(:tags) do |autocomplete| %>
    <% autocomplete.with_text_field(label: "Tags", placeholder: "Search") do |c| %>
      <% c.with_prefix do %>
        <%= polaris_icon(name: "SearchIcon") %>
      <% end %>
    <% end %>
    <% autocomplete.with_option(label: "Rustic", value: "rustic") %>
    <% autocomplete.with_option(label: "Antique", value: "antique") %>
    <% autocomplete.with_option(label: "Vinyl", value: "vinyl") %>
    <% autocomplete.with_option(label: "Vintage", value: "vintage") %>
    <% autocomplete.with_option(label: "Refurbished", value: "refurbished") %>
  <% end %>
<% end %>

Closes #348

Kurbm commented 6 months ago

Hey @k0va1 @kirillplatonov

are you sure, that this works? I get an error with missing method. I'm using the latest version of the view components.

undefined method polaris_autocomplete' for #<Polaris::FormBuilder:0x00000001118fb7d8 @nested_child_index={}, @options={:allow_method_names_outside_object=>true, :skip_default_ids=>false, :builder=>Polaris::FormBuilder}, @template=#<ActionView::Base:0x0000000004eb60>, @object=nil, @object_name=nil, @default_options={:skip_default_ids=>false, :allow_method_names_outside_object=>true}, @default_html_options={}, @multipart=nil, @index=nil>

Best, Kevin

kirillplatonov commented 6 months ago

@Kurbm just published v2.1.0 with this feature: https://github.com/baoagency/polaris_view_components/releases/tag/v2.1.0

Kurbm commented 6 months ago

Thanks a lot @kirillplatonov