Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo/Dijit: Dynamically choosing input required attribute
    primarykey
    data
    text
    <p>I am attempting to put together a fairly complex form using dojo and dijit widgets. The form has multiple 'sections' which allow the user to attach an existing object (via select tag) or create an entirely new object inline in the form.</p> <p>My inputs are rendered conditionally based radio buttons and manipulated via javascript. What I am having problems doing, is conditionally making dijit widgets required based on whether the inputs are rendered or not (which itself depends on which radio button is selected.</p> <p>My html (actually jsp)</p> <pre><code>&lt;div&gt; &lt;input id="useExisting" type="radio" name="radio" checked value="useExisting" onclick="renderExistingInput()" /&gt; &lt;label for="useExisting"&gt;Use Existing&lt;/label&gt; &lt;input id="new" type="radio" name="radio" value="new" onclick="renderNewInputs()"/&gt; &lt;label for="new"&gt;Create New&lt;/label&gt; &lt;/div&gt; &lt;br&gt; &lt;div id="newInputs"&gt; &lt;div class="row"&gt; &lt;label class="label" for="newName"&gt;Name &lt;/label&gt; &lt;span class="formInput"&gt;&lt;input type="text" id="newName" name="newName" required="true" dojoType="dijit.form.ValidationTextBox"/&gt;&lt;/span&gt; &lt;/div&gt; &lt;!-- More inputs with required="true"--&gt; &lt;br&gt; &lt;/div&gt; &lt;div id="existingInput&gt; &lt;div class="row"&gt; &lt;label class="label" for="existingSelect"&gt;Existing Object &lt;/label&gt; &lt;span class="formInput"&gt; &lt;select name="existingSelect" id="existingSelect" dojoType="dijit.form.Select"&gt; &lt;!--JSTL tags for compiling list of options --&gt; &lt;/select&gt; &lt;/span&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Accompanying javascript functions:</p> <pre><code>function renderExistingInput() { dojo.fx.wipeOut(getWipeArguments('newInputs')).play(); dojo.fx.wipeIn(getWipeArguments('existingInput')).play(); } function renderNewInputs() { dojo.fx.wipeOut(getWipeArguments('existingInput')).play(); dojo.fx.wipeIn(getWipeArguments('newInputs')).play(); } function getWipeArguments(id) { var wipeArgs = { node : id }; return wipeArgs; } </code></pre> <p>The basic 'flow' of user interactions is User clicks a radio button, the correct div renders as a result of that. What I want then are inputs that are not rendered to not be considered required. I'm not entirely sure how to do this. Is it possible to manipulate that particular attribute directly via dojo? Or is there a better way to do this entirely?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload