Last modified: 2014-02-12 23:37:59 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.).
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.
That does sounds reasonable - hopefully I or someone else can add this feature/fix in. ~~~~
(Ignore the tildes in my last comment. :) )
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 ); > } > } >
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.
... that was for SF 2.1.2