Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: add autocomplete to form builder #408

Merged

Conversation

k0va1
Copy link
Contributor

@k0va1 k0va1 commented Apr 17, 2024

<%= 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

@k0va1 k0va1 force-pushed the feature/add_autocomplete_to_formbuilder branch from 78b5e0a to 52f9055 Compare April 17, 2024 12:41
@k0va1 k0va1 changed the title [WIP] Autocomplete for forms Feature: add autocomplete to form builder Apr 17, 2024
@kirillplatonov kirillplatonov merged commit 867e75c into baoagency:main Apr 17, 2024
4 checks passed
@Kurbm
Copy link

Kurbm commented Apr 30, 2024

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
Copy link
Collaborator

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

@Kurbm
Copy link

Kurbm commented May 1, 2024

Thanks a lot @kirillplatonov

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Autocomplete component to Polaris::FormBuilder
3 participants