Created
September 22, 2023 07:13
-
-
Save Rio517/09c94c712048beb14dabf8282b53a72c to your computer and use it in GitHub Desktop.
demo-no-add-in-combobox.patch
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/assets/css/app.css b/assets/css/app.css | |
index 1316bc4..d34f635 100644 | |
--- a/assets/css/app.css | |
+++ b/assets/css/app.css | |
@@ -1,5 +1,6 @@ | |
@import "tailwindcss/base"; | |
@import "../../deps/petal_components/assets/default.css"; | |
+@import "../../deps/petal_framework/assets/css/combo-box.css"; | |
@import "tailwindcss/components"; | |
@import "tailwindcss/utilities"; | |
diff --git a/lib/petal_pro_web/live/user_settings/user_onboarding_live.ex b/lib/petal_pro_web/live/user_settings/user_onboarding_live.ex | |
index 898c708..b0507d5 100644 | |
--- a/lib/petal_pro_web/live/user_settings/user_onboarding_live.ex | |
+++ b/lib/petal_pro_web/live/user_settings/user_onboarding_live.ex | |
@@ -47,7 +47,7 @@ defmodule PetalProWeb.UserOnboardingLive do | |
</div> | |
</div> | |
<div class="mt-5 sm:mt-6"> | |
- <.form id="update_profile_form" for={@form} phx-submit="submit"> | |
+ <.form id="update_profile_form" for={@form} phx-submit="submit" phx-change="validate"> | |
<.field | |
field={@form[:name]} | |
label={gettext("What is your name?*")} | |
@@ -55,6 +55,14 @@ defmodule PetalProWeb.UserOnboardingLive do | |
{alpine_autofocus()} | |
/> | |
+ <.combo_box | |
+ label="Pick your favourite fruit" | |
+ options={["Apple", "Banana", "Orange", "Pineapple", "Strawberry"]} | |
+ field={@form[:fruit]} | |
+ create | |
+ tom_select_plugins={%{checkbox_options: false, remove_button: false}} | |
+ /> | |
+ | |
<.field | |
type="checkbox" | |
field={@form[:is_subscribed_to_marketing_notifications]} | |
@@ -75,6 +83,11 @@ defmodule PetalProWeb.UserOnboardingLive do | |
""" | |
end | |
+ def handle_event("validate", params, socket) do | |
+ changeset = Accounts.change_profile(socket.assigns.current_user, params) | |
+ {:noreply, assign(socket, form: to_form(changeset))} | |
+ end | |
+ | |
def handle_event("submit", %{"user" => user_params}, socket) do | |
user_params = Map.put(user_params, "is_onboarded", true) | |
current_user = socket.assigns.current_user |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment