Function components for rendering challenges inside forms.
Import them app-wide, e.g. in the html_helpers of my_app_web.ex:
import Wiztchta.Components
Summary
Functions
Renders a challenge plus the hidden token input. Place it inside any form.
Functions
Renders a challenge plus the hidden token input. Place it inside any form.
In controllers/dead views a fresh challenge is generated on every render:
<.form for={@form} action={~p"/contact"}>
...
<.wiztchta />
</.form>In LiveViews, keep the challenge in an assign so re-renders don't replace it, and assign a new one after each submit:
socket = assign(socket, :challenge, Wiztchta.new())
<.wiztchta challenge={@challenge} />Attributes
challenge(Wiztchta.Challenge) - a challenge fromWiztchta.new/1; generated on render when nil. Defaults tonil.type(:atom) - challenge module, when generating on render. Defaults tonil.opts(:list) - options forWiztchta.new/1, when generating on render. Defaults to[].id(:string) - DOM id; must be unique per page. Defaults to"wiztchta".name(:string) - form param name; defaults to the:paramconfig. Defaults tonil.class(:any) - Defaults tonil.- Global attributes are accepted.