PhoenixKit.Modules.Publishing.Web.Editor.Forms (phoenix_kit v1.7.39)

Copy Markdown View Source

Form building and management for the publishing editor.

Handles form construction, normalization, slug tracking, and form state management.

Summary

Functions

Assigns form with tracking for slug auto-generation.

Converts a published_at value to datetime-local input format.

Checks if the form has changes compared to the original post.

Floors a DateTime to the minute (sets seconds and microseconds to 0).

Updates slug from content if applicable. Returns {socket, new_form, slug_events}.

Normalizes a form map to ensure consistent values.

Builds a form map from a post.

Build form for a post, handling new translations appropriately.

Preserve auto-generated url_slug when browser sends empty value.

Push slug events to the client.

Updates form with selected media file.

Functions

assign_form_with_tracking(socket, form, opts \\ [])

Assigns form with tracking for slug auto-generation.

datetime_local_value(value)

Converts a published_at value to datetime-local input format.

dirty?(post, form, content)

Checks if the form has changes compared to the original post.

floor_datetime_to_minute(datetime)

Floors a DateTime to the minute (sets seconds and microseconds to 0).

maybe_update_slug_from_content(socket, content, opts \\ [])

Updates slug from content if applicable. Returns {socket, new_form, slug_events}.

normalize_form(form)

Normalizes a form map to ensure consistent values.

post_form(post)

Builds a form map from a post.

post_form_with_primary_status(blog_slug, post, version)

Build form for a post, handling new translations appropriately.

For new translations (no file on disk yet), inherits status from the primary language. For existing files, uses the file's own status to avoid confusion between what the dropdown shows and what the language switcher shows.

preserve_auto_url_slug(params, socket)

Preserve auto-generated url_slug when browser sends empty value.

push_slug_events(socket, events)

Push slug events to the client.

update_form_with_media(form, file_id)

Updates form with selected media file.