Last modified: 2014-02-12 23:37:59 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 T38505, the corresponding Phabricator task for complete and up-to-date bug report information.
Bug 36505 - When editing an existing page with a form that has a new field, the default for the new field should be set
When editing an existing page with a form that has a new field, the default f...
Status: NEW
Product: MediaWiki extensions
Classification: Unclassified
SemanticForms (Other open bugs)
unspecified
All All
: Unprioritized enhancement (vote)
: ---
Assigned To: Yaron Koren
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2012-05-04 05:03 UTC by Sal Quintanilla
Modified: 2014-02-12 23:37 UTC (History)
1 user (show)

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


Attachments

Description Sal Quintanilla 2012-05-04 05:03:55 UTC
Steps to replicate:

- Create a form
- Create page xyz with the form
- Modify the form and add radiobutton field abc, mandatory, with default=Yes and values=Yes,No
- Edit page xyz
=> Field abc will show None, Yes, and No, and None will be set.  If you save it without changing it, a warning will show up telling you that it needs to be set (to Yes or No).

The basis for SF is to not automatically modify existing data.  But in this case, the field didn't exist since it wasn't on the original page.  Setting it to the default in this case seems resonable and consistent, especially when considering that the field may not be obvious on the form (e.g. way down the page, or on tab 5, or under a hidden area, etc.).
Comment 1 Sal Quintanilla 2012-06-11 18:47:03 UTC
Any thoughts on this one way or another?  We're trying to introduce a new process flow system into our project pages, and this capability is going to greatly ease integration of existing pages.
Comment 2 Yaron Koren 2012-06-11 18:59:27 UTC
That does sounds reasonable - hopefully I or someone else can add this feature/fix in. ~~~~
Comment 3 Yaron Koren 2012-06-11 18:59:51 UTC
(Ignore the tildes in my last comment. :) )
Comment 4 Sal Quintanilla 2012-06-11 20:18:59 UTC
Thanks and done.  In the mean time, with respect to SF 2.4.2, moving the default or preloaded text assignment to $cur_value beneath the "If the user is editing a page, and that page contains a call to the template being processed, get the current field's value from the template call" code seems like the right thing to do to set fields that are mandatory and empty.  In testing it's doing the same thing it did before in all combinations of (mandatory/not mandatory) and (default/no default), with the exception that if the field is empty, it selects the default instead of None.

I know you don't necessarily have time to look at it now, but it's here in case you get an immediate fire alarm because of some side effect this causes that I've missed.

diff SF_FormPrinter.php.orig SF_FormPrinter.php
917,925d916
<                                       if ( empty( $cur_value ) && !$form_submitted ) {
<                                               if ( !is_null( $default_value ) ) {
<                                                       // Set to the default value specified in the form, if it's there.
<                                                       $cur_value = $default_value;
<                                               } elseif ( $preload_page ) {
<                                                       $cur_value = SFFormUtils::getPreloadedText( $preload_page );
<                                               }
<                                       }
<
953a945,953
>                                       if ( empty( $cur_value ) && !$form_submitted ) {
>                                               if ( !is_null( $default_value ) ) {
>                                                       // Set to the default value specified in the form, if it's there.
>                                                       $cur_value = $default_value;
>                                               } elseif ( $preload_page ) {
>                                                       $cur_value = SFFormUtils::getPreloadedText( $preload_page );
>                                               }
>                                       }
>
Comment 5 Sal Quintanilla 2012-06-15 15:06:40 UTC
Can't believe I cut-and-paste and posted that.  This is a little better:

--- D:/Projects/Internal/smwwiki/trunk/src/site/main/extensions/SemanticForms/includes/SF_FormPrinter.php	(revision 219)
+++ D:/Projects/Internal/smwwiki/trunk/src/site/main/extensions/SemanticForms/includes/SF_FormPrinter.php	(revision 260)
@@ -792,15 +792,6 @@
 						$cur_value = '';
 					}
 
-					if ( empty( $cur_value ) ) {
-						if ( $default_value ) {
-							// Set to the default value specified in the form, if it's there.
-							$cur_value = $default_value;
-						} elseif ( $preload_page ) {
-							$cur_value = SFFormUtils::getPreloadedText( $preload_page );
-						}
-					}
-
 					// if the user is editing a page, and that page contains a call to
 					// the template being processed, get the current field's value
 					// from the template call
@@ -816,6 +807,15 @@
 						}
 					}
 
+					if ( empty( $cur_value ) ) {
+						if ( $default_value ) {
+							// Set to the default value specified in the form, if it's there.
+							$cur_value = $default_value;
+						} elseif ( $preload_page ) {
+							$cur_value = SFFormUtils::getPreloadedText( $preload_page );
+						}
+					}
+
 					// Handle the free text field - if it was declared as
 					// "field|free text" (a deprecated usage), it has to be outside
 					// of a template.
Comment 6 Sal Quintanilla 2012-06-15 15:07:58 UTC
... that was for SF 2.1.2

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


Navigation
Links