You are here: Foswiki>Tasks Web>Item10874 (17 Dec 2011, GeorgeClark)Edit Attach

Item10874: Using "Add/change form" button saves fully-qualified Web.Topic name even if WEBFORMS = Topic

pencil
Priority: Urgent
Current State: Closed
Released In: 1.1.4
Target Release: patch
Applies To: Engine
Component: FoswikiUIChangeForm
Branches:
Reported By: PaulHarvey
Waiting For: PaulHarvey
Last Change By: GeorgeClark
IDEA! Please note, you may be unaffected by Foswikitask:Item10874 if:

Description

Any topics which have had a DataForm added or changed using the "Add/change form" button on the edit screen while running Foswiki 1.1.3 will now have "fully-qualified" Web.Topic names in the form.name MetaData even if the WEBFORMS preference variable omitted web prefixes from DataForm topic names. In other words, if you were using a WEBFORMS preference which looked like this:
   * Set WEBFORMS = MyForm

In Foswiki 1.1.3, the "Add/change form" button on the edit screen actually treats it like this:
   * Set WEBFORMS = TheWeb/TheSubWeb.MyForm

Having selected "MyForm", the form.name value is actually stored as TheWeb/SomeSubWeb.MyForm. This prevents QuerySearch type SEARCHes for an exact match on the topic-only value of form.name from working correctly, for example:
%SEARCH{"form.name='MyForm'" type="query" ...}%

... will not match these topics. Instead, a search on both possible values can be used:
%SEARCH{"form.name='MyForm' OR form.name='TheWeb/SomeSubWeb.MyForm'" type="query" ...}%

Or a regex query:
%SEARCH{"form.name=~'\bMyForm$'" type="query" ...}%

Hotfix

Solution

  • Change your QuerySearch SEARCHes from form.name='MyForm' to form.name=~'\bMyForm$' (see above), or
  • Use a search such as the following to identify all occurrences of fully-qualified form.name values (this assumes WEBFORMS only lists topic names):
    %SEARCH{"form.name~'*.*'" type="query" format="   * [[$web.$topic]] - <nop>$formname"}%
    , or
  • Use a search such as the following to identify all form.name values which don't match one of the WEBFORMS preference items:
    %SEARCH{
       "form.name AND %FORMAT{
         "%WEBFORMS%"
         header="NOT (form.name='"
         format="$item"
         separator="' OR form.name='"
         footer="')"
         type="string"
       }%"
       type="query"
       format="   * [[$web.$topic]] - <nop>$formname"
     }%
    , or
  • IDEA! Requires FilterPlugin
    Use a search such as the following to identify all form.name values which don't match one of the WEBFORMS preference items, and display a "fix" button which will remove the web prefix from the form.name value (preview here):
    #FixUp
     %IF{"NOT context FilterPluginEnabled" then="$percntX$percnt Please install Foswiki:Extensions.FilterPlugin!<div class='foswikiHidden'>"}%
     %SEARCH{
       "form.name AND %FORMAT{
         "%WEBFORMS%"
         header="NOT (form.name='"
         format="$item"
         separator="' OR form.name='"
         footer="')"
         type="string"
       }%"
       type="query"
       format="   * [[$web.$topic]] - =$formname= -> =$percntSUBST{
         text=\"$formname\"
         pattern=\"^($percntFORMATLIST{
           \"$web\"
           split=\"[.\\/]\"
           separator=\"[\\.\\/]\"
         }$percnt[\\.\\/])\"
       }$percnt= -
         <form action='%SCRIPTURL{"save"}%/$web/$topic' method='post'>
           <input type='hidden' name='redirectto' value='%BASEWEB%.%BASETOPIC%#FixUp'/>
           <input type='hidden' name='formtemplate' value='$percntSUBST{
         text=\"$formname\"
         pattern=\"^($percntFORMATLIST{
           \"$web\"
           split=\"[.\\/]\"
           separator=\"[\\.\\/]\"
         }$percnt[\\.\\/])\"
       }$percnt'/>
           <input type='submit' value='Fix' display='inline'/>
         </form>"
       pager="on"
       pagesize="25"
     }%%IF{"NOT context FilterPluginEnabled" then="</div>"}%
    

%STARTSECTION{"fixup"}%#FixUp
 %IF{"NOT context FilterPluginEnabled" then="$percntX$percnt Please install Foswiki:Extensions.FilterPlugin!<div class='foswikiHidden'>"}%
 %SEARCH{
   "form.name AND %FORMAT{
     "%WEBFORMS%"
     header="NOT (form.name='"
     format="$item"
     separator="' OR form.name='"
     footer="')"
     type="string"
   }%"
   type="query"
   format="   * [[$web.$topic]] - =$formname= -> =$percntSUBST{
     text=\"$formname\"
     pattern=\"^($percntFORMATLIST{
       \"$web\"
       split=\"[.\\/]\"
       separator=\"[\\.\\/]\"
     }$percnt[\\.\\/])\"
   }$percnt= -
     <form action='%SCRIPTURL{"save"}%/$web/$topic' method='post'>
       <input type='hidden' name='redirectto' value='%SCRIPTURL{"view"}%/%BASEWEB%.%BASETOPIC%?section=fixup#FixUp'/>
       <input type='hidden' name='formtemplate' value='$percntSUBST{
     text=\"$formname\"
     pattern=\"^($percntFORMATLIST{
       \"$web\"
       split=\"[.\\/]\"
       separator=\"[\\.\\/]\"
     }$percnt[\\.\\/])\"
   }$percnt'/>
       <input type='submit' value='Fix' display='inline'/>
     </form>"
   pager="on"
   pagesize="25"
 }%%IF{"NOT context FilterPluginEnabled" then="</div>"}%
%ENDSECTION{"fixup"}%

-- PaulHarvey - 14 Jun 2011

This work undoes the fix we tried in Item10446. So we need to find a different solution for that task as well, before we can close this one.

-- PaulHarvey - 14 Jun 2011

We now have two different tests (SaveTests and InitFormTests) covering Item10874 and Item10446 expected behaviours. Closing.

-- PaulHarvey - 18 Jun 2011
 
Topic revision: r23 - 17 Dec 2011, GeorgeClark
The copyright of the content on this website is held by the contributing authors, except where stated elsewhere. See Copyright Statement. Creative Commons License    Legal Imprint    Privacy Policy