Static form notice — alerts and banners with a known position, validation binding, dismiss tracking, and master-only restriction.
A notice is declared statically and rendered dynamically: the
position, type, and binding are pinned at compile time, while
visible / show_when / bind_to decide whether to actually render
on each frame. Five visual types (:info, :warning, :error,
:success, :neutral) and a custom HEEx render escape hatch cover
the common cases.
Positions
Atoms:
:form_top- above the<.form>element.:before_header/:after_header- around the form header.:before_groups/:before_fields- before grouped/ungrouped field rows.:before_submit- above the submit/cancel row.:form_bottom- below the submit row but inside<.form>.:form_footer- below the form footer (last possible slot).
Tuples:
{:before_group, :group_name}/{:after_group, :group_name}
Bind to (dynamic activation)
:validation- shown whenstate.form_errors != [].:uploads- shown when any registered upload has errors.:dirty- shown whenstate.dirty? == true.nil- no auto-binding; controlled solely byvisible/show_when.
Example
layout do
notice :read_only_banner do
position :before_fields
type :warning
title "Read-Only Access"
content "Your role can view but not modify these settings."
icon "hero-lock-closed"
visible fn state -> state.current_user.role == :viewer end
restricted false
dismissible false
end
notice :validation_summary do
position :form_top
type :error
bind_to :validation
title fn _state -> "Please fix the errors below" end
end
endSee MishkaGervaz.Form.Dsl.Layout for the surrounding section and
MishkaGervaz.Form.Entities.Notice.Ui for the ui sub-entity.
Summary
Functions
Validate a position value. Returns :ok or {:error, reason}.
Types
@type t() :: %MishkaGervaz.Form.Entities.Notice{ __identifier__: atom() | nil, __spark_metadata__: map() | nil, bind_to: :validation | :uploads | :dirty | nil, content: String.t() | (-> String.t()) | (map() -> String.t()) | nil, dismissible: boolean(), icon: String.t() | nil, name: atom(), only_steps: [atom()] | nil, position: position(), render: (map() -> Phoenix.LiveView.Rendered.t()) | (map(), map() -> Phoenix.LiveView.Rendered.t()) | nil, restricted: boolean() | (map() -> boolean()), show_when: (map() -> boolean()) | nil, title: String.t() | (-> String.t()) | (map() -> String.t()) | nil, type: :info | :warning | :error | :success | :neutral, ui: MishkaGervaz.Form.Entities.Notice.Ui.t() | nil, visible: boolean() | (map() -> boolean()) }