Alien-GvaScript
view release on metacpan or search on metacpan
doc/html/Form.html view on Meta::CPAN
for children, the resulting tree would be</p>
<pre> { "father" : {"firstname" : ..., "lastname": ...},
"mother" : {"firstname" : ..., "lastname": ...},
"child" : [ {"firstname": ...},
{"firstname": ...},
{"firstname": ...} ] }</pre>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>
</div>
</div>
<div class="TN_node" id="fill_from_tree">
<h3 class="TN_label">fill_from_tree</h3>
<div class="TN_content">
<pre> GvaScript.Form.fill_from_tree(form, field_prefix, tree);</pre>
<p>Fills the form from values found in <code>tree</code> (this is the
reverse of the <a href="#to_tree">/to_tree</a> operation).
Optional <code>field_prefix</code> is prepended to key names in <code>tree</code> for
finding the corresponding form fields.</p>
<p>The method walks through nested subtrees in <code>tree</code>: the sequence
of keys leading to a leaf is concatenated into a flat string, with dot
separators, and if the form has a corresponding input element,
the value of that element is set to the value of the leaf.
Furthermore, if the initial tree contains repeated data sets
(array subtrees), and if the form contains repeat elements
with the same path, then new repetition blocks are
dynamically created to match the number of items in the array:
so if the form above is filled with the following tree</p>
<pre> { "child" : [ {"firstname": "Abel"},
{"firstname": "Bob"},
{"firstname": "Cod"},
{"firstname": "Dave"}, ] }</pre>
<p>then four repetition blocks will automatically created in the form.</p>
<p>[<i>This method can be called either as an instance method or as a generic method. If calling as a generic, pass the form HTMLElement/id in as the first argument.</i>]</p>
</div>
</div>
<div class="TN_node" id="add">
<h3 class="TN_label">add</h3>
<div class="TN_content">
<pre> GvaScript.Form.add(repeat_name, count);</pre>
<p>Creates one or several new repetition blocks. The parameter <code>count</code>
is optional and defaults to 1. Focus is automatically given to the
first input element in the last repetition block that has an
<code>autofocus</code> attribute (if any).</p>
<p>See <i>Alien::GvaScript::Repeat/add</i> for more explanations on
the <code>add</code> operation.</p>
</div>
</div>
<div class="TN_node" id="remove">
<h3 class="TN_label">remove</h3>
<div class="TN_content">
<pre> GvaScript.Form.remove(repeat_block[, live_update]);</pre>
<p>Removes a repetition block from the DOM. The argument is either
a DOM element or a string containing the element id.</p>
<p>param <code>Boolean</code> live_update: flag to indicate whether the 'remaining'
repeatable sections are to be also removed from DOM, recreated by re-merging
the data with repeat template, then finally re-appended to the DOM.
Default true.</p>
<p>All repetition blocks above the removed block are renumbered,
leaving no hole in the index sequence. To do so, these
blocks are also removed from the DOM, and then added
again through the <a href="#add">/add</a> method. This operation is implemented
by <i>Alien::GvaScript::Repeat/remove</i>.</p>
<p>The recreated blocks are then re-populated with their
previous input values.</p>
</div>
</div>
<div class="TN_node" id="autofocus">
<h3 class="TN_label">autofocus</h3>
<div class="TN_content">
<pre> GvaScript.Form.autofocus(element);</pre>
<p>Inspects DOM children of <code>element</code>, and gives focus to the
first child that has an <code>autofocus</code> attribute.</p>
</div>
</div>
</div>
</div>
<div class="TN_node" id="GvaScript_Forms">
<h2 class="TN_label">GvaScript.Forms</h2>
<div class="TN_content">
<p>namespace that holds all active instances of GvaScript.Form</p>
<p>instances are unique per form id</p>
<div class="TN_node" id="METHODS">
<h3 class="TN_label">METHODS</h3>
<div class="TN_content">
<div class="TN_node" id="get">
<h4 class="TN_label">get</h4>
<div class="TN_content">
<pre> GvaScript.Forms.get(id)</pre>
<p>finds and returns the GvaScript.Form instance where id is the unique id of the form HTMLElement.</p>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="TN_node" id="GvaScript_Form_Responders">
<h2 class="TN_label">GvaScript.Form.Responders</h2>
<div class="TN_content">
<p>A repository of global listeners notified about every step of the GvaSript.Form lifecycle.</p>
<p>Sometimes, you need to provide generic behaviors over all GvaScript.Form(s) in a single application.</p>
<p>To achieve this, GvaScript.Form provides global Responders that will be executed for every GvaScript.Form instance.</p>
<p>Responders by default are executed <b>after</b> the instance specific event callback.</p>
<div class="TN_node" id="METHODS">
<h3 class="TN_label">METHODS</h3>
<div class="TN_content">
<div class="TN_node" id="register">
( run in 0.736 second using v1.01-cache-2.11-cpan-119454b85a5 )