This question about Using an extension: Answered

MetaDataPlugin no longer respects form option values(?)

Hi, there's been a change in behavior in how MetaDataPlugin handles data from select-type form entries that broke functionality in one of my applications until I figured out it was due to updating the plugin and fixed it. Simple example, if this was your meta data form:

Name Type Size Values Tooltip message Attributes
Letter select+values 1 1=a,2=b   M

This correctly shows "1," "2" in the drop-down dialog, and has value="a", value="b" in the option tag when the page source is viewed, in all versions of MetaDataPlugin.

My problem is this: in past versions of MetaDataPlugin, had you selected "1," when you called RENDERMETADATA and had it write out $Letter, it would write out "a." In newer versions (not sure when the change was implemented; my "old" version is the "10 Jul 2013" revision), when you write out $Letter, it writes out "1." I believe this is unintended behavior because it's disregarding the "values" type in the form definition, and it means some useful things no longer work (for example, it may make sense to have something long and complicated e.g. with spaces as the visible option, but to have the underlying value be a WikiWord).

I don't know exactly what caused the change in behavior, but a temporary fix for me has been to replace the lib/Foswiki/Plugins/MetaDataPlugin folder and lib/Foswiki/Plugins/MetaDataPlugin.pm file with the 10 Jul 2013 revision versions copied from one of my backups, so whatever changed was in those files. If anyone else tries this: I have no idea if this will cause anything weird to happen, as I left all the other included MetaDataPlugin files on their most recent version, but I at least haven't noticed any ill effects from doing this.

-- JasonMerritt - 03 Jun 2014

By default RENDERMETADATA renders the "display value" visible to the user. Under the hood you still have the original value, "a" or "b" in your case.

The format a field is rendered is controlled by the fieldformat parameter which defaults to $value. Change it to $origvalue to render the original value as stored in the meta data record.

Here's how to render both per formfield:

%RENDERMETADATA{
  "MyTestData"
  fieldformat="value=$value origvalue=$origvalue"
}%

-- MichaelDaum - 03 Jun 2014

Worked like a charm! Good feature to have, too. Thanks for the help and all the work on the software!

-- JasonMerritt - 03 Jun 2014
 

QuestionForm edit

Subject Using an extension
Extension MetaDataPlugin
Version Foswiki 1.1.9
Status Answered
Related Topics
Topic revision: r3 - 03 Jun 2014, JasonMerritt
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