madhu
madhu
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
let me start from scratch with
sh <(curl 'https://ash-hq.org/install/virtual_reality_yoga?install=phoenix') \
&& cd virtual_reality_yoga && mix igniter.install ash ash_phoenix \
ash_postgres ash_authentication ash_authentication_phoenix ash_admin \
live_debugger mishka_chelekom --auth-strategy password \
--auth-strategy magic_link --yes && mix ash.setup
sh <(curl 'https://ash-hq.org/install/virtual_reality_yoga?install=phoenix') \
&& cd virtual_reality_yoga && mix igniter.install ash ash_phoenix \
ash_postgres ash_authentication ash_authentication_phoenix ash_admin \
live_debugger mishka_chelekom --auth-strategy password \
--auth-strategy magic_link --yes && mix ash.setup
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
ok
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
defmodule ObanDashboardWeb.UserProfileLive do
use ObanDashboardWeb, :live_view
alias ObanDashboard.UserProfile
alias ObanDashboard.Accounts.User
import Ash.Filter
import Ash.Expr
require Ash.Query

# import AshPhoenix.FormComponents

on_mount {ObanDashboardWeb.LiveUserAuth, :live_user_required}

@timezones [
"Etc/UTC",
"America/New_York",
"Europe/London",
"Asia/Kolkata",
"Asia/Tokyo",
"Australia/Sydney"
]

@impl true
def mount(_params, _session, socket) do
user = socket.assigns[:current_user]

query =
ObanDashboard.UserProfile
|> Ash.Query.filter(expr(user_id == ^user.id))

profile =
case Ash.read!(query, domain: ObanDashboard.Domain) do
[profile] -> profile
_ -> nil
end

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true]
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: %{
user_id: user.id,
firstname: "",
lastname: "",
timezone: "Etc/UTC"
}
)
end

{:ok,
assign(socket,
form: form |> to_form(),
profile: profile,
user: user,
success: nil,
timezones: @timezones
)}
end

@impl true
def handle_event("save", %{"user_profile" => params}, socket) do
user = socket.assigns.user
profile = socket.assigns.profile

params = Map.put(params, "user_id", user.id)

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: params
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: params
)
end

# Note: No to_form! Just assign :form
case form.source.action_result do
{:ok, profile} ->
{:noreply, assign(socket, profile: profile, form: form |> to_form(), success: true)}

_ ->
{:noreply, assign(socket, form: form |> to_form(), success: false)}
end
end

@impl true
def render(assigns) do
~H"""
<.simple_form for={@form} phx-submit="save">
<.input
form={@form}
field={:email}
label="Email"
readonly
value={(@profile && @profile.email) || @user.email}
class="w-full px-3 py-2 border rounded bg-gray-100"
/>
<.input
form={@form}
field={:firstname}
label="First Name"
class="w-full px-3 py-2 border rounded"
/>
<.input
form={@form}
field={:lastname}
label="Last Name"
class="w-full px-3 py-2 border rounded"
/>
<.input
form={@form}
field={:timezone}
type="select"
options={@timezones}
label="Timezone"
class="w-full px-3 py-2 border rounded"
/>
<:actions>
<.button class="mt-4 bg-indigo-600 text-white px-4 py-2 rounded">
Save
</.button>
</:actions>
</.simple_form>
"""
end
end
defmodule ObanDashboardWeb.UserProfileLive do
use ObanDashboardWeb, :live_view
alias ObanDashboard.UserProfile
alias ObanDashboard.Accounts.User
import Ash.Filter
import Ash.Expr
require Ash.Query

# import AshPhoenix.FormComponents

on_mount {ObanDashboardWeb.LiveUserAuth, :live_user_required}

@timezones [
"Etc/UTC",
"America/New_York",
"Europe/London",
"Asia/Kolkata",
"Asia/Tokyo",
"Australia/Sydney"
]

@impl true
def mount(_params, _session, socket) do
user = socket.assigns[:current_user]

query =
ObanDashboard.UserProfile
|> Ash.Query.filter(expr(user_id == ^user.id))

profile =
case Ash.read!(query, domain: ObanDashboard.Domain) do
[profile] -> profile
_ -> nil
end

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true]
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: %{
user_id: user.id,
firstname: "",
lastname: "",
timezone: "Etc/UTC"
}
)
end

{:ok,
assign(socket,
form: form |> to_form(),
profile: profile,
user: user,
success: nil,
timezones: @timezones
)}
end

@impl true
def handle_event("save", %{"user_profile" => params}, socket) do
user = socket.assigns.user
profile = socket.assigns.profile

params = Map.put(params, "user_id", user.id)

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: params
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: params
)
end

# Note: No to_form! Just assign :form
case form.source.action_result do
{:ok, profile} ->
{:noreply, assign(socket, profile: profile, form: form |> to_form(), success: true)}

_ ->
{:noreply, assign(socket, form: form |> to_form(), success: false)}
end
end

@impl true
def render(assigns) do
~H"""
<.simple_form for={@form} phx-submit="save">
<.input
form={@form}
field={:email}
label="Email"
readonly
value={(@profile && @profile.email) || @user.email}
class="w-full px-3 py-2 border rounded bg-gray-100"
/>
<.input
form={@form}
field={:firstname}
label="First Name"
class="w-full px-3 py-2 border rounded"
/>
<.input
form={@form}
field={:lastname}
label="Last Name"
class="w-full px-3 py-2 border rounded"
/>
<.input
form={@form}
field={:timezone}
type="select"
options={@timezones}
label="Timezone"
class="w-full px-3 py-2 border rounded"
/>
<:actions>
<.button class="mt-4 bg-indigo-600 text-white px-4 py-2 rounded">
Save
</.button>
</:actions>
</.simple_form>
"""
end
end
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
I am first time trying with ash phoenix form component, I am not getting clue my complete component as shown below
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
ok
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
<.input form={@form} field={:email} label="Email" readonly class="w-full px-3 py-2 border rounded bg-gray-100" /> this line, the email coming from ash_authentication user profile
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
@impl true
def render(assigns) do
~H"""
<.simple_form for={@form} phx-submit="save">
<.input form={@form} field={:email} label="Email" readonly class="w-full px-3 py-2 border rounded bg-gray-100" />
<.input form={@form} field={:firstname} label="First Name" class="w-full px-3 py-2 border rounded" />
<.input form={@form} field={:lastname} label="Last Name" class="w-full px-3 py-2 border rounded" />
<.input
form={@form}
field={:timezone}
type="select"
options={@timezones}
label="Timezone"
class="w-full px-3 py-2 border rounded"
/>
<:actions>
<.button class="mt-4 bg-indigo-600 text-white px-4 py-2 rounded">
Save
</.button>
</:actions>
</.simple_form>
"""
end
@impl true
def render(assigns) do
~H"""
<.simple_form for={@form} phx-submit="save">
<.input form={@form} field={:email} label="Email" readonly class="w-full px-3 py-2 border rounded bg-gray-100" />
<.input form={@form} field={:firstname} label="First Name" class="w-full px-3 py-2 border rounded" />
<.input form={@form} field={:lastname} label="Last Name" class="w-full px-3 py-2 border rounded" />
<.input
form={@form}
field={:timezone}
type="select"
options={@timezones}
label="Timezone"
class="w-full px-3 py-2 border rounded"
/>
<:actions>
<.button class="mt-4 bg-indigo-600 text-white px-4 py-2 rounded">
Save
</.button>
</:actions>
</.simple_form>
"""
end
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
@impl true
def mount(_params, _session, socket) do
user = socket.assigns[:current_user]

query =
ObanDashboard.UserProfile
|> Ash.Query.filter(expr(user_id == ^user.id))

profile =
case Ash.read!(query, domain: ObanDashboard.Domain) do
[profile] -> profile
_ -> nil
end

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true]
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: %{
user_id: user.id,
firstname: "",
lastname: "",
timezone: "Etc/UTC"
}
)
end

{:ok,
assign(socket,
form: form |> to_form(),
profile: profile,
user: user,
success: nil,
timezones: @timezones
)}
end
@impl true
def mount(_params, _session, socket) do
user = socket.assigns[:current_user]

query =
ObanDashboard.UserProfile
|> Ash.Query.filter(expr(user_id == ^user.id))

profile =
case Ash.read!(query, domain: ObanDashboard.Domain) do
[profile] -> profile
_ -> nil
end

form =
if profile do
AshPhoenix.Form.for_update(profile, :update,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true]
)
else
AshPhoenix.Form.for_create(UserProfile, :create,
as: "user_profile",
api: ObanDashboard,
forms: [auto?: true],
params: %{
user_id: user.id,
firstname: "",
lastname: "",
timezone: "Etc/UTC"
}
)
end

{:ok,
assign(socket,
form: form |> to_form(),
profile: profile,
user: user,
success: nil,
timezones: @timezones
)}
end
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
key :name not found in: %{
id: nil,
label: "Email",
type: "text",
prompt: nil,
field: :email,
errors: [],
rest: %{
form: %Phoenix.HTML.Form{
source: #AshPhoenix.Form<
resource: ObanDashboard.UserProfile,
action: :create,
type: :create,
params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
source: #Ash.Changeset<
domain: ObanDashboard.Domain,
action_type: :create,
action: :create,
attributes: %{timezone: "Etc/UTC"},
relationships: %{},
errors: [],
data: %ObanDashboard.UserProfile{
user: #Ash.NotLoaded<:relationship, field: :user>,
__meta__: #Ecto.Schema.Metadata<:built, "user_profiles">,
id: nil,
user_id: nil,
firstname: nil,
lastname: nil,
timezone: "Etc/UTC",
inserted_at: nil,
updated_at: nil
},
valid?: true
>,
name: "user_profile",
data: nil,
form_keys: [],
forms: %{},
domain: ObanDashboard.Domain,
method: "post",
submit_errors: nil,
id: "user_profile",
transform_errors: nil,
original_data: nil,
transform_params: nil,
prepare_params: nil,
prepare_source: nil,
raw_params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
warn_on_unhandled_errors?: true,
any_removed?: false,
added?: false,
changed?: false,
touched_forms: MapSet.new([:user_id, :firstname, :lastname, :timezone]),
valid?: true,
errors: nil,
submitted_once?: false,
just_submitted?: false,
...
>,
impl: Phoenix.HTML.FormData.AshPhoenix.Form,
id: "user_profile",
name: "user_profile",
data: nil,
action: nil,
hidden: [
_touched: "user_id,firstname,lastname,timezone",
_form_type: "create"
],
params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
errors: [],
options: [method: "post"],
index: nil
},
readonly: true,
class: "w-full px-3 py-2 border rounded bg-gray-100"
},
__changed__: nil,
multiple: false,
__given__: %{label: "Email", field: :email, __changed__: nil}
}
key :name not found in: %{
id: nil,
label: "Email",
type: "text",
prompt: nil,
field: :email,
errors: [],
rest: %{
form: %Phoenix.HTML.Form{
source: #AshPhoenix.Form<
resource: ObanDashboard.UserProfile,
action: :create,
type: :create,
params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
source: #Ash.Changeset<
domain: ObanDashboard.Domain,
action_type: :create,
action: :create,
attributes: %{timezone: "Etc/UTC"},
relationships: %{},
errors: [],
data: %ObanDashboard.UserProfile{
user: #Ash.NotLoaded<:relationship, field: :user>,
__meta__: #Ecto.Schema.Metadata<:built, "user_profiles">,
id: nil,
user_id: nil,
firstname: nil,
lastname: nil,
timezone: "Etc/UTC",
inserted_at: nil,
updated_at: nil
},
valid?: true
>,
name: "user_profile",
data: nil,
form_keys: [],
forms: %{},
domain: ObanDashboard.Domain,
method: "post",
submit_errors: nil,
id: "user_profile",
transform_errors: nil,
original_data: nil,
transform_params: nil,
prepare_params: nil,
prepare_source: nil,
raw_params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
warn_on_unhandled_errors?: true,
any_removed?: false,
added?: false,
changed?: false,
touched_forms: MapSet.new([:user_id, :firstname, :lastname, :timezone]),
valid?: true,
errors: nil,
submitted_once?: false,
just_submitted?: false,
...
>,
impl: Phoenix.HTML.FormData.AshPhoenix.Form,
id: "user_profile",
name: "user_profile",
data: nil,
action: nil,
hidden: [
_touched: "user_id,firstname,lastname,timezone",
_form_type: "create"
],
params: %{
user_id: "3b06a43b-d8af-4500-b5b9-fcbcb15168f3",
firstname: "",
lastname: "",
timezone: "Etc/UTC"
},
errors: [],
options: [method: "post"],
index: nil
},
readonly: true,
class: "w-full px-3 py-2 border rounded bg-gray-100"
},
__changed__: nil,
multiple: false,
__given__: %{label: "Email", field: :email, __changed__: nil}
}
I am getting this error not able to resolve
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
my dependency {:ash_phoenix, "~> 2.3"}, why I am not able do import AshPhoenix.FormComponents
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
ok
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
I am doing this "phoenix_form = AshPhoenix.FormData.to_form(form, as: "user_profile")" still same issue
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
ok sure, thank you
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
application stuck
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
I am. not able to render form at all
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
form = if profile do AshPhoenix.Form.for_update(profile, :update, as: "user_profile", api: ObanDashboard, forms: [auto?: true], params: params ) else AshPhoenix.Form.for_create(UserProfile, :create, as: "user_profile", api: ObanDashboard, forms: [auto?: true], params: params ) end # phoenix_form = AshPhoenix.FormData.to_form(form, as: "user_profile") phoenix_form = form case form.source.action_result do {:ok, profile} -> {:noreply, assign(socket, profile: profile, form: form, phoenix_form: phoenixform, success: true)} -> {:noreply, assign(socket, form: form, phoenix_form: phoenix_form, success: false)} end
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
core components - 402 "<input type={@type} name={@name} id={@id} value={Phoenix.HTML.Form.normalize_value(@type, @value)} class={[ "mt-2 block w-full rounded-lg text-zinc-900 focus:ring-0 sm:text-sm sm:leading-6", @errors == [] && "border-zinc-300 focus:border-zinc-400", @errors != [] && "border-rose-400 focus:border-rose-400" ]} {@rest} />"
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
<.input form={@phoenix_form} name="user_profile[email]" value={@user.email} field={:email} label="Email" readonly class="w-full px-3 py-2 border rounded bg-gray-100" /> -- 109
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
(phoenix_html 4.2.1) lib/phoenix_html/safe.ex:1: Phoenix.HTML.Safe.impl_for!/1 (phoenix_html 4.2.1) lib/phoenix_html/safe.ex:15: Phoenix.HTML.Safe.to_iodata/1 (phoenix_html 4.2.1) lib/phoenix_html.ex:244: Phoenix.HTML.build_attrs/1 (phoenix_html 4.2.1) lib/phoenix_html.ex:197: Phoenix.HTML.attributes_escape/1 (oban_dashboard 0.1.0) lib/oban_dashboard_web/components/core_components.ex:402: anonymous fn/2 in ObanDashboardWeb.CoreComponents."input (overridable 1)"/1 (oban_dashboard 0.1.0) /Users/amf-elixir-2025/oban_dashboard/lib/oban_dashboard_web/live/user_profile_live.ex:109: ObanDashboardWeb.UserProfileLive.render/1 (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:412: Phoenix.LiveView.Diff.traverse/7 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:555: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7 (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:412: Phoenix.LiveView.Diff.traverse/7 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:555: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7 (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:412: Phoenix.LiveView.Diff.traverse/7 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:555: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7 (elixir 1.18.1) lib/enum.ex:2546: Enum."-reduce/3-lists^foldl/2-0-"/3 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:412: Phoenix.LiveView.Diff.traverse/7 (phoenix_live_view 1.0.11) lib/phoenix_live_view/diff.ex:555: anonymous fn/4 in Phoenix.LiveView.Diff.traverse_dynamic/7
43 replies
AEAsh Elixir
Created by madhu on 5/20/2025 in #support
Getting protocol Phoenix.HTML.Safe not implemented with "Ash Phoenix"
defprotocol Phoenix.HTML.Safe do first line I am getting this error
43 replies