{"result":{"depiction_url":null,"edges":{"hasreference":{"objects":[{"created":"2026-10-07T11:13:41Z","object_id":{"id":1539,"is_a":["text","documentation","developerguide"],"name":"doc_developerguide_wires","title":{"_type":"trans","tr":{"en":"Handle a browser event with a wire"}},"uri":"https:\/\/zotonic.com\/id\/1539"},"seq":1},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2950,"is_a":["text","documentation","developerguide"],"name":"developer_resource_identifiers","title":{"_type":"trans","tr":{"en":"Use stable resource names"}},"uri":"https:\/\/zotonic.com\/id\/2950"},"seq":2}],"predicate":{"id":2774,"is_a":["meta","predicate"],"name":"hasreference","title":{"_type":"trans","tr":{"en":"Documentation reference"}},"uri":"https:\/\/zotonic.com\/id\/hasreference"}},"subject":{"objects":[{"created":"2026-10-07T11:13:41Z","object_id":{"id":2557,"is_a":["categorization","keyword","keyword_information_type"],"name":"zotonic_topic_cookbook_recipe","title":"Cookbook recipe","uri":"https:\/\/zotonic.com\/id\/2557"},"seq":1},{"created":"2026-10-07T11:13:41Z","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-07T11:13:41Z","object_id":{"id":2582,"is_a":["categorization","keyword","keyword_domain"],"name":"zotonic_topic_forms","title":"Forms","uri":"https:\/\/zotonic.com\/id\/2582"},"seq":3},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2624,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_wire_action","title":"Wire action","uri":"https:\/\/zotonic.com\/id\/2624"},"seq":4},{"created":"2026-10-07T11:13:41Z","object_id":{"id":2620,"is_a":["categorization","keyword","keyword_architecture"],"name":"zotonic_topic_template","title":"Template","uri":"https:\/\/zotonic.com\/id\/2620"},"seq":5}],"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":1592,"is_a":["text","documentation","cookbook"],"links":[{"rel":"self","target":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1592"},{"rel":"hub","target":"https:\/\/zotonic.com\/.zotonic\/websub"}],"medium":null,"medium_url":null,"name":"doc_cookbook_frontend_template_select_value","page_url":{"en":"https:\/\/zotonic.com\/cookbook\/1592\/update-a-preview-from-a-selection","x-default":"https:\/\/zotonic.com\/cookbook\/1592\/update-a-preview-from-a-selection"},"preview_url":null,"resource":{"body":{"_type":"trans","tr":{"en":"<p>Use a wired change event to update part of a page. This example offers two known resources; create them with names <code>garden_rose<\/code> and <code>garden_tree<\/code> first.<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;label for=&quot;{{ #choice }}&quot;&gt;{_ Choose a plant _}&lt;\/label&gt;\n&lt;select id=&quot;{{ #choice }}&quot; name=&quot;plant&quot;&gt;\n    &lt;option value=&quot;&quot;&gt;{_ Choose… _}&lt;\/option&gt;\n    &lt;option value=&quot;garden_rose&quot;&gt;{_ Rose _}&lt;\/option&gt;\n    &lt;option value=&quot;garden_tree&quot;&gt;{_ Tree _}&lt;\/option&gt;\n&lt;\/select&gt;\n&lt;div id=&quot;{{ #preview }}&quot;&gt;&lt;\/div&gt;\n{% wire id=#choice type=&quot;change&quot;\n        postback={plant_preview target=#preview} delegate=&quot;mod_garden&quot; %}\n<\/code><\/pre>\n<p>In the active <code>mod_garden<\/code>, include <code>zotonic.hrl<\/code>, export <code>event\/2<\/code>, and merge this clause into its existing handler:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-erlang\">event(#postback{message = {plant_preview, Args}}, Context) -&gt;\n    Name = z_context:get_q(&lt;&lt;&quot;triggervalue&quot;&gt;&gt;, Context),\n    case lists:member(Name, [&lt;&lt;&quot;garden_rose&quot;&gt;&gt;, &lt;&lt;&quot;garden_tree&quot;&gt;&gt;]) of\n        true -&gt;\n            Id = m_rsc:rid(Name, Context),\n            case m_rsc:is_visible(Id, Context) of\n                true -&gt;\n                    Target = proplists:get_value(target, Args),\n                    z_render:update(Target, &quot;_garden_plant_preview.tpl&quot;,\n                                    [{id, Id}], Context);\n                false -&gt; z_render:growl_error(&lt;&lt;&quot;This plant is unavailable.&quot;&gt;&gt;, Context)\n            end;\n        false -&gt;\n            z_render:growl_error(&lt;&lt;&quot;Choose a plant from the list.&quot;&gt;&gt;, Context)\n    end.\n<\/code><\/pre>\n<p>Create <code>priv\/templates\/_garden_plant_preview.tpl<\/code>:<\/p>\n<pre class=\"notranslate\"><code class=\"notranslate language-django\">&lt;h2&gt;{{ id.title }}&lt;\/h2&gt;\n{% if id.depiction %}{% image id.depiction width=300 %}{% endif %}\n<\/code><\/pre>\n<p>Compile, refresh module discovery, then change the selection. Expect the corresponding visible page&#39;s title and image. Test an empty value, a manually altered value and a restricted resource as a visitor. The signed postback carries the target; the submitted selection remains untrusted. For a large dynamic list, validate against its actual allowed resource set instead of this fixed list.<\/p>"}},"category_id":{"id":318,"is_a":["meta","category"],"name":"cookbook","title":{"_type":"trans","tr":{"en":"Cookbook"}},"uri":"https:\/\/test.zotonic.com\/id\/318"},"content_group_id":{"id":339,"is_a":["meta","content_group"],"name":"default_content_group","title":{"_type":"trans","tr":{"en":"Default Content Group"}},"uri":"https:\/\/zotonic.com\/id\/default_content_group"},"created":"2020-05-30T05:47:27Z","creator_id":{"id":336,"is_a":["person","robot"],"name":"gitbot","title":"Git","uri":"https:\/\/zotonic.com\/id\/336"},"doc_editorial_bundle":true,"doc_editorial_edges":{"hasreference":[1539,2950],"subject":[2557,2563,2582,2620,2624]},"github_url":"https:\/\/github.com\/zotonic\/zotonic\/tree\/master\/doc\/cookbook\/frontend-template-select-value.rst","is_authoritative":true,"is_dependent":false,"is_featured":false,"is_protected":false,"is_published":true,"is_unfindable":false,"language":["en"],"modified":"2026-10-07T11:13:51Z","modifier_id":{"id":1,"is_a":["person"],"name":"administrator","title":"Site Administrator","uri":"https:\/\/zotonic.com\/id\/1"},"name":"doc_cookbook_frontend_template_select_value","pivot_geocode":null,"pivot_location_lat":null,"pivot_location_lng":null,"privacy":0,"publication_end":"9999-06-01T00:00:00Z","publication_start":"2022-02-15T10:01:42Z","slug":"update-a-preview-from-a-selection","summary":{"_type":"trans","tr":{"en":"Validate a selection before rendering a resource preview."}},"title":{"_type":"trans","tr":{"en":"Update a preview from a selection"}},"title_slug":{"_type":"trans","tr":{"en":"update-a-preview-from-a-selection"}},"tz":"UTC","uri":null,"version":35,"visible_for":0},"uri":"https:\/\/zotonic.com\/id\/1592","uri_template":"https:\/\/zotonic.com\/id\/:id","websub":{"hub":"https:\/\/zotonic.com\/.zotonic\/websub","topic":"https:\/\/zotonic.com\/.zotonic\/websub\/topic\/1592"}},"status":"ok"}