Page MenuHomePhabricator

Adding a "default noparse" option to form fields
Closed, DeclinedPublic

Description

This patch adds an aditional formfield option "default noparse". This can be used if the default value should not be parsed first, e.g. when used with the Substitutor Extension.

This also makes sense for multiple instance templates, where the default value for new instances is just copied and not recalculated. If you want unique ID's for each new instance, this mechanism wouldn't work.

(I've tested this patch with single instance templates, multiple instance template still seem broken at the moment, see T125377

patch
index 6c3a18d..f79356d 100644
--- a/includes/SF_FormField.php
+++ b/includes/SF_FormField.php
@@ -219,6 +219,8 @@ class SFFormField {
                                        // wikitext in the value, and bare URLs,
                                        // will not get turned into HTML.
                                        $f->mDefaultValue = $wgParser->recursivePreprocess( $sub_components[1] );
+                               } elseif ( $sub_components[0] == 'default noparse' ) {
+                                       $f->mDefaultValue = $sub_components[1];
                                } elseif ( $sub_components[0] == 'preload' ) {
                                        $f->mPreloadPage = $sub_components[1];
                                } elseif ( $sub_components[0] == 'show on select' ) {
@@ -332,7 +334,7 @@ class SFFormField {
                }

                // If we're using Cargo, there's no equivalent for "values from
-               // property" - instead, we just always get the values if a
+               // property" - instead, we just always get the values if a
                // field and table have been specified.
                if ( is_null( $f->mPossibleValues ) && defined( 'CARGO_VERSION' ) && $cargo_table != null && $cargo_field != null ) {
                        // We only want the non-null values. Ideally this could

Event Timeline

Fannon assigned this task to Yaron_Koren.
Fannon raised the priority of this task from to Needs Triage.
Fannon updated the task description. (Show Details)
Fannon subscribed.
This comment was removed by Fannon.

Could this be done instead with <nowiki> around the value?

No, because then it won't be parsed after it was saved, too.

But I've already solved this problem with my Substitutor extension. It
behaves like a <nowiki> tag, but will parse once the page is actually saved.

Alright. I'm setting this to "Declined" - its good to have this option in mind, but I will hold off on adding it in unless there turns out to be a real need for it.