{"result":{"depiction_url":null,"edges":{"in_module":{"objects":[{"created":"2026-10-23T14:41:16Z","object_id":{"id":1303,"is_a":["text","documentation","reference","module"],"name":"doc_module_mod_wires","title":"mod_wires","uri":"https:\/\/zotonic.com\/id\/1303"},"seq":1}],"predicate":{"id":333,"is_a":["meta","predicate"],"name":"in_module","title":{"_type":"trans","tr":{"en":"In module"}},"uri":"https:\/\/zotonic.com\/id\/in_module"}},"subject":{"objects":[{"created":"2026-10-23T14:41:16Z","object_id":{"id":2555,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_reference","title":"Reference","uri":"https:\/\/zotonic.com\/id\/2555"},"seq":1},{"created":"2026-10-23T14:41:16Z","object_id":{"id":2563,"is_a":["categorization","keyword","keyword_audience"],"name":"zotonic_topic_frontend_developer","title":"Frontend developer","uri":"https:\/\/zotonic.com\/id\/2563"},"seq":2},{"created":"2026-10-23T14:41:16Z","object_id":{"id":2583,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_user_interface_and_interaction","title":"User interface and interaction","uri":"https:\/\/zotonic.com\/id\/2583"},"seq":3},{"created":"2026-10-23T14:41:16Z","object_id":{"id":2625,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_model","title":"Model","uri":"https:\/\/zotonic.com\/id\/2625"},"seq":4},{"created":"2026-10-23T14:41:16Z","object_id":{"id":2673,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_javascript","title":"JavaScript","uri":"https:\/\/zotonic.com\/id\/2673"},"seq":5},{"created":"2026-10-23T14:41:16Z","object_id":{"id":2718,"is_a":["categorization","keyword","keyword_technology"],"name":"zotonic_topic_cotonic","title":{"_type":"trans","tr":{"en":"Cotonic"}},"uri":"https:\/\/zotonic.com\/id\/2718"},"seq":6}],"predicate":{"id":308,"is_a":["meta","predicate"],"name":"subject","title":{"_type":"trans","tr":{"en":"Keyword"}},"uri":"http:\/\/purl.org\/dc\/elements\/1.1\/subject"}}},"id":3118,"is_a":["text","documentation","reference","cotonic_reference","cotonic_model"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/3118"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_zotonic_cotonic_model_password","page_url":{"en":"https:\/\/zotonic.com\/cotonic\/zotonic-models\/password","x-default":"https:\/\/zotonic.com\/cotonic\/zotonic-models\/password"},"preview_url":null,"resource":{"version":21,"pivot_location_lat":null,"title":"model\/password","is_authoritative":true,"body":"<h1>model\/password<\/h1>\n<p>Toggles password visibility in the browser. Implemented in the wires script,\nloaded by the standard Zotonic JavaScript includes. It works with dynamically\nrendered forms through Cotonic&#39;s delegated DOM events, without inline JavaScript\nor rebinding click handlers after a template update.<\/p>\n<h2>Template usage<\/h2>\n<p>With <code>mod_authentication<\/code> enabled, use its shared button template after a password\ninput, inside an <code>input-group<\/code> container. Pass the input&#39;s HTML ID as <code>target_id<\/code>:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;div class=&quot;input-group&quot;&gt;\n    &lt;input class=&quot;form-control&quot; type=&quot;password&quot; id=&quot;new-password&quot; name=&quot;password&quot;\n           autocomplete=&quot;new-password&quot; required&gt;\n    {% include &quot;_password_visibility.tpl&quot; target_id=&quot;new-password&quot; %}\n&lt;\/div&gt;\n<\/code><\/pre>\n<p>The partial provides an attached eye-icon button with a translated <strong>Show password<\/strong>\naccessible label and tooltip, a generated ID,\n<code>type=&quot;button&quot;<\/code>, <code>aria-controls<\/code>, <code>aria-pressed<\/code>, and <code>data-onclick-topic<\/code>.\nThe eye is crossed out while the password is visible.\nEach password field can have its own button. Include buttons only for fields\nthat the user can interact with, not hidden password fields in intermediate\nlogin or two-factor steps.<\/p>\n<p>For a custom button, use the same attributes and give both elements unique IDs:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;input type=&quot;password&quot; id=&quot;account-password&quot; name=&quot;password&quot;\n       autocomplete=&quot;current-password&quot;&gt;\n&lt;button type=&quot;button&quot; id=&quot;account-password-toggle&quot;\n        aria-controls=&quot;account-password&quot; aria-pressed=&quot;false&quot;\n        data-onclick-topic=&quot;model\/password\/post\/toggle&quot;&gt;\n    {_ Show password _}\n&lt;\/button&gt;\n<\/code><\/pre>\n<p>Keep the label stable: <code>aria-pressed=&quot;true&quot;<\/code> indicates that showing the password\nis enabled. Native buttons support mouse and keyboard activation without\nsubmitting the form.<\/p>\n<h2>post\/toggle<\/h2>\n<p>Topic: <code>model\/password\/post\/toggle<\/code>.<\/p>\n<p>The payload must contain <code>message.id<\/code>, the ID of the <strong>button<\/strong>, not the input.\nCotonic&#39;s <code>data-onclick-topic<\/code> handling supplies this from the button attributes.\nA direct publish from an already loaded script has the same shape:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-javascript\">cotonic.broker.publish(&quot;model\/password\/post\/toggle&quot;, {\n    message: { id: &quot;account-password-toggle&quot; }\n});\n<\/code><\/pre>\n<p>The handler requires a button with the matching <code>data-onclick-topic<\/code>. It reads\n<code>aria-controls<\/code> and searches for the input inside the button&#39;s form, or the\ndocument if the button has no form. Inputs must have type <code>password<\/code> or <code>text<\/code>.\nMissing buttons, missing inputs, and disabled inputs are ignored.<\/p>\n<p>The input type switches between <code>password<\/code> and <code>text<\/code>, and the button&#39;s\n<code>aria-pressed<\/code> becomes <code>false<\/code> or <code>true<\/code> respectively. The existing input element,\nvalue, name, and autocomplete attributes are preserved.<\/p>\n<p>This is a local browser topic. The toggle handler does not read or publish the\npassword value, contact the server, return a reply, or publish a result event.\nDo not include password values in toggle messages.<\/p>\n<h2>Template updates<\/h2>\n<p>The model also subscribes to <code>model\/ui\/event\/dom-updated\/+key<\/code>. The event payload&#39;s\n<code>id<\/code> identifies the updated DOM container. Its toggle buttons and associated\ninputs are reset to <code>aria-pressed=&quot;false&quot;<\/code> and <code>type=&quot;password&quot;<\/code>, including when\nIncremental DOM has reused an input that was previously revealed. The input value\nis preserved. The container itself is also handled if it is a toggle button.<\/p>\n<p>Visibility is not persisted across these updates. New templates should render\npassword inputs masked and their toggle buttons unpressed. Replacing a form does\nnot require registering new click handlers.<\/p>\n<h2>Implementation<\/h2>\n<p><a href=\"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_mod_wires\/priv\/lib\/js\/apps\/zotonic-wired.js\">JavaScript source<\/a>.<\/p>\n<p><a href=\"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/apps\/zotonic_mod_authentication\/priv\/templates\/_password_visibility.tpl\">Shared button template<\/a>.<\/p>","slug":"model-password","is_protected":false,"visible_for":0,"tz":"UTC","language":["en"],"doc_source_hash":"25666a117ed1db62e79e978011213900effca73f09badbaaac2d0f69dd053a79","is_featured":false,"content_group_id":{"id":2551,"is_a":["meta","content_group"],"name":"content_group_imported_docs","title":"Imported documentation","uri":"https:\/\/zotonic.com\/id\/content_group_imported_docs"},"category_id":{"id":2723,"is_a":["meta","category"],"name":"cotonic_model","title":"Cotonic models","uri":"https:\/\/zotonic.com\/id\/cotonic_model"},"doc_source_path":"doc\/cotonic-models\/password.md","publication_start":"2026-10-23T14:41:16Z","page_path":"\/cotonic\/zotonic-models\/password","github_url":"https:\/\/github.com\/zotonic\/zotonic\/blob\/master\/doc\/cotonic-models\/password.md","pivot_location_lng":null,"doc_source_kind":"cotonic_model","name":"doc_zotonic_cotonic_model_password","is_unfindable":false,"is_published":true,"pivot_geocode":null,"created":"2026-10-23T14:41:16Z","uri":null,"doc_status":"current","is_dependent":false,"publication_end":"9999-06-01T00:00:00Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"privacy":0,"doc_source_commit":"bb8c4bfc7674f55f71ccc1d9130a01760b8031bc\n","creator_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"modified":"2026-10-24T06:47:23Z","title_slug":"model-password"},"uri":"https:\/\/zotonic.com\/id\/3118","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/3118"}},"status":"ok"}