https://bugzilla.wikimedia.org/show_bug.cgi?id=37231

       Web browser: ---
             Bug #: 37231
           Summary: SF: validation does not work for new instances of
                    multi-instance templates.
           Product: MediaWiki extensions
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: Unprioritized
         Component: SemanticForms
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]
    Classification: Unclassified
   Mobile Platform: ---


SemanticForms 2.4.1.

I have implemented a new input type. My type has validation function but does
not have initialization function:

> // NOT CALLED: $this->addJsInitFunctionData( 'mytype.init' );
> $this->addJsValidationFunctionData( 'mytype.validate' );

Everything works ok, but new instances of multi-instance template are not
validated. The problem is in SemanticForms.js file, line ~ 867:

> var sfdata = jQuery("#sfForm").data('SemanticForms');
> if ( sfdata && sfdata.initFunctions[old_id] ) { // found data object?
>     // For every initialization method for
>     // input with id old_id, register the
>     // method for the new input.
>     for ( var i = 0; i < sfdata.initFunctions[old_id].length; i++ ) {
>         jQuery(this).SemanticForms_registerInputInit(
>             sfdata.initFunctions[old_id][i].initFunction,
>             sfdata.initFunctions[old_id][i].parameters,
>             true //do not yet execute
>         );
>     }
>     // For every validation method for the
>     // input with ID old_id, register it
>     // for the new input.
>     for ( var i = 0; i < sfdata.validationFunctions.length; i++ ) {
>         if ( sfdata.validationFunctions[i].input == old_id ) {
>             jQuery(this).SemanticForms_registerInputValidation(
>                 sfdata.validationFunctions[i].valfunction,
>                 sfdata.validationFunctions[i].parameters
>             );
>         }
>     }
> }

Yo see, that registering both initialization and validation functions are under
the same condition -- if initialization function exist. I think it would be
better to decouple it, so validation works regardless of initialization.

-- 
Configure bugmail: https://bugzilla.wikimedia.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

_______________________________________________
Wikibugs-l mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/wikibugs-l

Reply via email to