dijit.InlineEditBox editWidget is undefined

So I have a save all button to save all dijit.form elements at once, but first I wanted to make sure that they were all valid. Piece of cake, all of them have isValid() methods so all I have to do is loop through them all and check to see if they are all valid… wrong.

Apparently you can not access the editor, editWidget, editNode etc of an dijit.InlineEditBox until AFTER it has already been displayed. This is retarded since it is HIGHLY likely that a user won’t open every edit box on the page *sigh*. This took some digging in the source code to find out, but if you look at the edit() function for dijit.InlineEditBox around line 190:


if(this.wrapperWidget){
this.wrapperWidget.editWidget.attr("displayedValue" in this.editorParams ? "displayedValue" : "value", this.value);
}else{
// Placeholder for edit widget
// Put place holder (and eventually editWidget) before the display node so that it's positioned correctly
// when Calendar dropdown appears, which happens automatically on focus.
var placeholder = dojo.create("span", null, this.domNode, "before");

// Create the editor wrapper (the thing that holds the editor widget and the save/cancel buttons)
var ewc = dojo.getObject(this.editorWrapper);
this.wrapperWidget = new ewc({
value: this.value,
buttonSave: this.buttonSave,

You see that the editor isn’t created until the actual edit function is called. So basically to force all editors to be created:


try{
inlineeditbox.edit();
// THIS IS UNDEFINED until edit();
inlineeditbox.wrapperWidget.editWidget.isValid();
}
catch(e){
console.log('Editor doesn't have validation');
}

How to Force a User to Check a Single Checkbox

Basically you just need to trigger a validation error. I do this by making the unchecked value equal to an empty string and adding the NotEmpty validator.


$this->addElement('checkbox', 'agreement', array(
'label' => 'I agree with all the statements.',
'filters' => array(
'StringTrim'
),
'validators' => array(
array('NotEmpty', true, array('messages' => 'Must check.')),
),
'uncheckedValue' => '', /* This causes a blank value when not check which causes NotEmpty validation to trigger. */
'required' => true
));