defmodule LivebookWeb.EnvVarComponent do use LivebookWeb, :live_component alias Livebook.Settings alias Livebook.Settings.EnvVar @impl true def update(assigns, socket) do {env_var, operation} = if assigns.env_var, do: {assigns.env_var, :edit}, else: {%EnvVar{}, :new} changeset = Settings.change_env_var(env_var) {:ok, socket |> assign(assigns) |> assign(changeset: changeset, env_var: env_var, operation: operation)} end @impl true def render(assigns) do assigns = assign_new(assigns, :on_save, fn -> "save" end) ~H"""
<%= @headline %>
<.form :let={f} id={"#{@id}-form"} for={@changeset} phx-submit={@on_save} phx-change={JS.push("validate", target: @myself)} autocomplete="off" spellcheck="false" >