Last modified: 2014-02-12 23:38:01 UTC

Wikimedia Bugzilla is closed!

Wikimedia migrated from Bugzilla to Phabricator. Bug reports are handled in Wikimedia Phabricator.
This static website is read-only and for historical purposes. It is not possible to log in and except for displaying bug reports and their history, links might be broken. See T39231, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 37231 - SF: validation does not work for new instances of multi-instance templates.
SF: validation does not work for new instances of multi-instance templates.
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
SemanticForms (Other open bugs)
unspecified
All All
: Unprioritized normal (vote)
: ---
Assigned To: s7eph4n
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-30 21:05 UTC by Van de Bugger
Modified: 2014-02-12 23:38 UTC (History)
0 users

See Also:
Web browser: ---
Mobile Platform: ---
Assignee Huggle Beta Tester: ---


Attachments

Description Van de Bugger 2012-05-30 21:05:28 UTC
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.
Comment 1 Yaron Koren 2013-12-27 04:00:58 UTC
I should have obviously done this a long time ago, but: reassigning to Stephan, who wrote the JS registration code for form inputs.

Note You need to log in before you can comment on or make changes to this bug.


Navigation
Links