multitopicsave
of the plugin
editmode="on"
. The field types are text, textarea, radio, checkbox, and select (all the formats supported by the plugin). The macro MULTITOPICSAVEINPUT can also just show the current value with editmode="off"
delay
allows you to do that without using ugly $percnt and $quot everywhere
<!-- * Set TYPES = %SEARCH{"\| *Type *\|" topic="MultiTopicSaveTestForm" regex="on" nonoise="on" multiple="on" format="$pattern(.*?\| *Type *\|[^\|]*\|[^\|]*\| *([^\|]*?) *\|.*)"}% * Set ANIMALS = %SEARCH{"\| *Animal *\|" topic="MultiTopicSaveTestForm" regex="on" nonoise="on" multiple="on" format="$pattern(.*?\| *Animal *\|[^\|]*\|[^\|]*\| *([^\|]*?) *\|.*)"}% * Set FRIENDS = %SEARCH{"\| *Friend *\|" topic="MultiTopicSaveTestForm" regex="on" nonoise="on" multiple="on" format="$pattern(.*?\| *Friend *\|[^\|]*\|[^\|]*\| *([^\|]*?) *\|.*)"}% --> %MULTITOPICSAVESTARTFORM% %IF{"$ multiedit = 'on'" then="[[%TOPIC%][Cancel editing and release locks]] , %MULTITOPICSAVESUBMIT{"Save all changes"}%" else="[[%TOPICURL%?multiedit=on][Edit and lock the topics]]"}% %TABLE{columnwidths="180,200,140,100,100"}% |* Topic/Option * | *Description* | *Type* | *Animal* | *Friend* | %SEARCH{"MultiTopicSaveTestTarget" scope="topic" nonoise="on" format="| $topic <br /> \ %MULTITOPICSAVEINPUT{"Option" type="text" size="20" web="$web" topic="$topic" value="$value" delay="1" editmode="%URLPARAM{"multiedit" default="off"}%" lockmode="on"}% | \ %MULTITOPICSAVEINPUT{"Description" type="textarea" web="$web" topic="$topic" size="25x6" value="$value" delay="1" editmode="%URLPARAM{"multiedit" default="off"}%" lockmode="on"}% | \ %MULTITOPICSAVEINPUT{"Type" type="radio" size="1" delay="1" web="$web" topic="$topic" value="$value" options="%TYPES%" editmode="%URLPARAM{"multiedit" default="off"}%" lockmode="on"}% | \ %MULTITOPICSAVEINPUT{"Animal" type="checkbox" size="1" delay="1" web="$web" topic="$topic" value="$value" options="%ANIMALS%" editmode="%URLPARAM{"multiedit" default="off"}%" lockmode="on"}% | \ %MULTITOPICSAVEINPUT{"Friend" type="select" size="0" multiple="on" delay="1" web="$web" topic="$topic" value="$value" options="%FRIENDS%" editmode="%URLPARAM{"multiedit" default="off"}%" lockmode="on"}% |" }% %MULTITOPICSAVEENDFORM% %MULTITOPICSAVEMESSAGE%
<form action='%SCRIPTURL{"rest"}%/MultiTopicSavePlugin/multitopicsave' method='post'> </form>To make is easier to make a form two macros %MULTITOPICSAVESTARTFORM% and %MULTITOPICSAVEENDFORM% creates the <form action=... > and the </form> In the form you need to define fields that must have the name:
multitopicsavefield{Webname.Topicname}{Fieldname}
where the Webname.Topicname is the fully qualified name of the target topic and the Fieldname is the name of the form field you want to change.
Example
<input type='text' size='20' name='multitopicsavefield{Myweb.MultiTopicSaveTestTarget2}{Name}' value='$formfield(Name}' />To ease this task you will normally use the MULTITOPICSAVEINPUT macro to generate the correct fields. Most standard HTML formfield types are supported. You have pretty good control of the fields using the macro but if you need a special way to present the fields you can also use plain HTML. The important detail is that the name of the field must be
name='multitopicsavefield{Webname.Topicname}{Fieldname}'
In addition the form must submit two hidden fields redirectweb and redirecttopic that specify the topic to which you are redirected when you submit.
<input type='hidden' name='redirectweb' value='Myweb' /> <input type='hidden' name='redirecttopic' value='MultiTopicSaveTest' />To ease this task you will normally use the MULTITOPICSAVESUBMIT which creates a submit button and per default redirects the user back to the original topic from which the form was submitted.
<form action='%SCRIPTURL{"rest"}%/MultiTopicSavePlugin/multitopicsave' method='post'>
</form>
%MULTITOPICSAVESUBMIT{"Submit button text" returnweb="webname" returntopic="topicname"}%
returnweb
and returntopic
are optional and by default current topic and web. This is used when the topic with the MULTITOPICSAVESUBMIT is included in another topic. Otherwise you return to the included topic after submit. Simply use them with %BASEWEB% and %BASETOPIC% as values.
%MULTITOPICSAVESUBMIT{"Submit button text" returnweb="%BASEWEB%" returntopic="%BASETOPIC%"}%
%MULTITOPICSAVEINPUT{"Field name" type="field type" multiple="on|off" size="field size" web="webname" topic="topicname" value="desplayed value in field" options="list of options"}%
Parameter | Description | Default |
---|---|---|
"fieldname" | The name of the field in the data form. If the field name has spaces you need to ommit the spaces | |
type="text" | type of input field. Valid types are text , textarea , radio , checkbox , select , and hidden | text |
multiple="on" | Allow multiple values for fields of the select type. For other types of fields this parameter is ignored | off |
size="1" | The size of the input field • For text type field the size is the field width in characters. Default is 10. • For textarea type field the size if specified as columns x rows (width x height).Default for textarea is '80x4' for 80 columns wide by 4 lines tall. • For checkbox and radio type fields the size defines the number of buttons/checkboxes shown before in each displayed row of buttons/checkboxes. To show all the buttons in one row select a very large number. To show them all below each other set size to 1. Default is 1. • For select type field the size defines the number of values displayed in the input window. If no size is given all values are shown for multiple fields and a simple pulldown is shown for non-multiple. • For hidden type fields size is ignored | Depends on type |
web="..." | Web of the target topic. In formatted searches you can put $web here | Current web |
topic="..." | Name of the target topic. In formatted searches you can put $topic here | Current topic |
value="$value" | The value that is put in the field by default. You can use the token $value and let the plugin fetch the current value from the formfield. This also enables you to prefix or postfix text or values before and after the current value. If value is not specified the default will be value='$value' | $value |
options="..,..,.." | The values to choose between for types radio, select etc. This value is ignored for text, textarea, and hidden. Options are separated by commas, example: options="dog, cat, horse". Note that for performance reasons the options are not fetched from the form defining topic. You must provide the list. | none |
editmode="off" | Enable the field in edit mode. If this is set to "off" the value given in the value field is shown. If editmode is "on" the field is shown in edit mode. By default the editmode it "on". This enables selectively to enable editing by adding something like editmode="%URLPARAM{"multiedit" default="off"}% to MULTITOPICSAVEINPUT and control selectively if fields are editable or not. This can simply be used by appending ?multiedit=on to the URL. | on |
encodeview="off" | By default the value returned by MULTITOPICSAVEINPUT with editmode="off" is encoded to enable display of textareas inside TML tables. The encoding changes newlines to <br /> and | to |. This encoding is not always desired and can be turned off by setting encodeview="off". This feature is mostly relevant with text and textarea type fields | on |
lockmode="on" | Lock topics when editmode="on" and unlock them when editmode="off". If lockmode is enabled and a topic is being edited by someone else or you have no edit access rights, the field will be rendered as if editmode is off. Ie. the value is shown in plain text. | off |
delay="1" | Number of times the MULTITOPICSAVEINPUT will delay its own expansion by changing the first and last %-sign to $percnt and all double quotes (") to $quot. This is used when you use MULTITOPICSAVEINPUT inside the format parameter of a SEARCH macro and you do not want to expand MULTITOPICSAVEINPUT until the SEARCH is completed. Set the delay to 1 if it is a single level SEARCH. If you have nested SEARCHes you can set delay to the level of nesting. | 0 |
placeholder="..." | A placeholder text shown in the browser when the text field is empty. The purpose is to help the user. The placeholder text is not saved. It is only displayed in the browser when the field is empty | none |
%MULTITOPICSAVEINPUT{"Field name" type="text" size="field size" web="webname" topic="topicname" value="$value" placeholder="placeholder text" delay="number" editmode="on|off" lockmode="on|off" encodeview="on|off"}%
This is the most simple type. This creates a plain text field which has a width given by the size parameter. When using this type of field in a format of a SEARCH you may choose not to use the value="$value". If the text never contains quotes (") you can with get a small performance gain by using value="$formfield(fieldname)" and delay="0" because this means MULTITOPICSAVEINPUT only gets expanded once per page view. But often people will use quotes in the text so be careful with this approach. It is safer to use value="$value" and delay="1".
If your text fields contain vertical bars and you use MULTITOPICSAVEINPUT in a TML table, the table will break in editmode, because the encoding of '|' and newlines happens only with editmode="off". You can instead use a textarea type field with height 1 as this will handle the vertical bars well.
Example of use in formatted search format
%MULTITOPICSAVEINPUT{"Option" type="text" size="20" web="$web" topic="$topic" value="$value" placeholder="Please enter name of customer" delay="1" editmode="on" lockmode="off"}%Or taking advantage of the default values for the parameters we can simply use
%MULTITOPICSAVEINPUT{"Option" size="20" web="$web" topic="$topic" delay="1"}%
%MULTITOPICSAVEINPUT{"Field name" type="textarea" size="COLxROWS" web="webname" topic="topicname" value="$value" delay="number" editmode="on|off" lockmode="on|off" encodeview="on|off"}%
The textarea produces a text entry field with width and number of displayed lines as defined by the size parameter. Size is given as "20x4" for 4 lines of 20 characters each. You can input more than the 4 lines. The browser will add a scroll bar to the field.
Note that for textareas we cannot use the SEARCH feature $formfield
because it always encodes newlines as <br /> (to avoid breaking tables) which is not desired when you want to show the current exact content in a text box while editing. For textarea use the $value token which returns the textarea field as raw unrendered text. When we use $value we have to delay the expansion of MULTITOPICSAVEINPUT till after the SEARCH has completed so we need to set the delay
parameter.
Example of use in formatted search format
%MULTITOPICSAVEINPUT{"Description" type="textarea" web="$web" topic="$topic" size="20x4" value="$value" delay="1"}%Example of use outside a table where we do not want any encoding in non-edit mode. And additionally we control edit mode by a URL parameter 'multiedit' and we use the topic locking feature.
%MULTITOPICSAVEINPUT{"Description" type="textarea" web="Myweb" topic="TopicName" size="100x20" value="$value" encodeview="off" editmode="%URLPARAM{"multiedit" default="off"}% lockmode="on" }%
%MULTITOPICSAVEINPUT{"Field name" type="radio|checkbox" size="options per line" web="webname" topic="topicname" value="$value" options="list of options" delay="number" editmode="on|off" lockmode="on|off" encodeview="on|off"}%
Radio buttons allows you to select one value of many. It is not possible to unselect all in the browser once one is selected.
Checkboxes allow multiple values to be checked and you can unselect all values.
Values listed (comma separated if more than one for checkbox fields) will be checked when page is loaded in the browser.
In formatted searches where we use MULTITOPICSAVEINPUT inside the format parameter of the SEARCH we have to delay the expansion with the delay
parameter. The reason is that MULTITOPICSAVEINPUT needs to know the current value of the field for each found topic to be able to show the right radio button as checked. Without the delay the MULTITOPICSAVEINPUT would be expanded before the SEARCH is run and the topic would be viewed topic which has no form. The result will be that none of the buttons/checkboxes/select fields will be be selected when viewed.
The size defines how many options will be displayed in a row. If you have 6 options and set the size as 2 you will see 3 rows with 2 buttons/checkboxes in each.
The options parameter defines the values that will be presented. You define the options as a comma separated text string. Example: options="cat, mouse, dog and pony, elephant". Leading and trailing whitespace is removed from each value. Each value can be multiple words. The plugin will not automatically generate the options list for you as this would have a performance impact. See [auto generating the options list for a tip how to automatically generate the list with minimal performance hit.
Both radio buttons and checkboxes are shown with the value to the right of the button/checkbox.
Example of radio button field in formatted search format using delay of the expansion of MULTITOPICSAVEINPUT
%MULTITOPICSAVEINPUT{"Type" type="radio" size="2" delay="1" web="$web" topic="$topic" value="$value" options="Boolean, Integer, String, Discrete Strings"}%Example of checkbox field in formatted search format - again using the delay feature
%MULTITOPICSAVEINPUT{"Default" type="checkbox" size="2" delay="1" web="$web" topic="$topic" value="$value" options="ape, cat, elephant, mouse"}%
%MULTITOPICSAVEINPUT{"Field name" type="select" multiple="on|off" size="number of shown options" web="webname" topic="topicname" value="$value" options="list of options" delay="number" editmode="on|off" lockmode="on|off" encodeview="on|off"}%
The select field presents the values as a pull down list or scrollable list depending of the size. The select fields can be single value or multiple value. Multiple values are selected by using control + mouseclick.
The size parameter defines the number of values displayed in the input window. If no size is given all values are shown for multiple fields and a simple pulldown is shown for non-multiple. A size of 1 will give a pulldown window if it is not a multiple value field. If there are more options than given by the size the browser will add a scroll bar.
Values listed (comma separated if multiple values) will be pre-selected when page is loaded in the browser.
And again we delay the expansion of MULTITOPICSAVEINPUT with the delay feature
%MULTITOPICSAVEINPUT{"Friends" type="select" size="0" multiple="on" delay="1" web="$web" topic="$topic" value="$value" options="ape, cat, elephant, mouse" }%
%MULTITOPICSAVEINPUT{"Field name" type="hidden" web="webname" topic="topicname" value="$value" delay="number" lockmode="on|off" encodeview="on|off"}%
Hidden fields allow submitting values without displaying them to the user. This type is typically used in combination with radio, checkbox or select when you want to add additional values to a multiple value field without showing the existing values to the user.
For example. You have many topics with a field with combinations of values A, B and C. You want to let the user add the value D to many of the topics by selecting a single checkbox and a single submit. We use a combination of a hidden field and a checkbox field with the same field name. The hidden field is given the existing values. The SEARCH is made so it only shows the topic that do not have the value D.
%SEARCH{"NOT(Platforms ~ '*D*') AND name ~ 'FuncReq*'" type="query" nonoise="on" format="| [[$topic][$formfield(Title)]] |%MULTITOPICSAVEINPUT{"Platforms" type="hidden" web="$web" topic="$topic" value="$value" delay="1" }% %MULTITOPICSAVEINPUT{"Platforms" type="checkbox" size="1" multiple="on" web="$web" topic="$topic" value="" options="D" delay="1"}% |"}%
* Set PLATFORMOPTIONS = %SEARCH{"\| *Platforms *\|" topic="RequirementsForm" regex="on" nonoise="on" multiple="on" format="$pattern(.*?\| *Platforms *\|[^\|]*\|[^\|]*\| *([^\|]*?) *\|.*)"}%You can then use options="%PLATFORMOPTIONS%" in MULTITOPICSAVEINPUT If the option values are defined in their own topic use instead this example The topic called
FieldName
defines the values in a table like
Name | Type | Tooltip message |
---|---|---|
Open | option | Not yet resolved |
Closed | option | Fixed and closed |
Rejected | option | Not accepted and closed |
* Set FIELDOPTIONS = %SEARCH{ "^\|[^\|]*\| *option *\|" topic="FieldName" type="regex" multiple="on" nonoise="on" separator=", " format="$pattern(^\| *(.*?) *\|.*)" }%
editmode
parameter for MULTITOPICSAVEINPUT add editmode="%URLPARAM{"multiedit" default="off"}% to MULTITOPICSAVEINPUT.
This will disable editing and just show the plain content given in the value option.
At the top of the page put a link like this [[%TOPICURL%?multiedit=on][Edit the requirements]]
. When the user clicks the link the page is reloaded and all fields will be in edit mode. A bit like we know from EditTablePlugin.
Note that if you use editmode="off" and you have textarea fields it is difficult to use MULTITOPICSAVEINPUT inside a TML table because the newlines break the table row into multiple lines and that does not work with TML. Instead you can use HTML tables.
<form action='%SCRIPTURL{"rest"}%/MultiTopicSavePlugin/multitopicsave' method="post"> %IF{"$ multiedit = 'on'" then="[[%TOPIC%][Cancel Editing]] , %MULTITOPICSAVESUBMIT{"Save Hiddenfield"}%" else="[[%TOPICURL%?multiedit=on][Edit Hiddenfield]]"}% %MULTITOPICSAVEINPUT{"Hiddenfield" type="textarea" size="80x4" editmode="%URLPARAM{"multiedit" default="off"}%"}% </form>
configure
, then you can still install manually from the command-line. See http://foswiki.org/Support/ManuallyInstallingExtensions for more help.
Change History: | |
26 Jan 2016 (1.12) | Foswikitask:Item13934: Unescaped { in regex fails on perl 5.22. |
24 Nov 2015 (1.11) | Foswikitask:Item13868: Add TOPICINFO to the Extension topic. |
27 Jul 2015 (1.10) | Added placeholder option to MULTITOPICSAVEINPUT for text type fields |
04 Jul 2015 (1.9) | Call multi_param, not param, to process lists. |
25 Jul 2014 (1.8) | Added the ability to treat the topic text as a field called 'text' |
12 Sep 2010 (1.7) | Fixed a problem with handling single quotes and html tags in text fields Disabled topic editing and saving for guests. |
19 Aug 2010 (1.6) | Added returnweb and returntopic to MULTITOPICSAVESUBMIT |
08 Mar 2010 (1.5) | Added MULTITOPICSAVESTARTFORM and MULTITOPICSAVEENDFORM. Fixed problem where TML tables were destroyed when you edit but a topic is locked or protected and therefore displayed in view mode Fixed problem rendering fields with the value 0 (zero) Made is clearer that the plugin bundles a demo application in Sandbox web |
21 Feb 2010 (1.4) | Added parameter lock mode. Using this you can make applications without fear of edit conflicts between concurrent users Value option for MULTITOPICSAVEINPUT now accepts the token $value so users can let the plugin fetch the current value for the formfield. Added foswikiButton CSS class to the MULTITOPICSAVESUBMIT button for nice rendering. Fixed a problem where using the delay feature for MULTITOPICSAVEINPUT would cause the plugin to also turn double quotes that are part of a field value into $quot More documentation improvements Added default values to size for text/textarea fields Added encoding of newlines and vertical bars for MULTITOPICSAVEINPUT in non-edit mode. Added new parameter encodeview to MULTITOPICSAVEINPUT so you can disable the encoding of newlines and vertical bars Added working example application in Sandbox web |
17 Feb 2010 (1.3) | Added the parameter editmode to MULTITOPICSAVEINPUT which can be used to show the value instead of an edit field. Fixed bug where options were wrongly selected if they matched a substring of the one of the values. Fixed bug where the count of saved topics gets too high if you change multiple fields Fixed bug where same topic was saved for each field changed causing performance impact Added the parameter delay for MULTITOPICSAVEINPUT so you can avoid un-readable code when escaping % and " using $percnt and $quot Improved documentation further adding tips and tricks including search patterns for picking lists of options from forms |
17 Feb 2010 (1.2) | Added MULTITOPICSAVEMESSAGE macro so the user can get feedback on how the saving went |
17 Feb 2010 (1.1) | Added type hidden. Added examples of use of all the different field types |
16 Feb 2010 (1.0) | First version of plugin |
Author | Foswiki:Main.KennethLavrsen |
Version | 1.12 |
Release | 1.12 |
Description | Save form data to multiple topics in one single submission |
Copyright | © 2010-2015, Kenneth Lavrsen |
License | GPL (GNU General Public License) |
Home | http://foswiki.org/Extensions/MultiTopicSavePlugin |
Support | http://foswiki.org/Support/MultiTopicSavePlugin |
Repository | https://github.com/foswiki/MultiTopicSavePlugin |
ExtensionClassification | User interactivity |
ExtensionType | PluginPackage |
Compatibility | |
ImageUrl | |
DemoUrl | http:// |
SupportUrl | MultiTopicSavePlugin |
ModificationPolicy | PleaseFeelFreeToModify |
I | Attachment | Action | Size | Date | Who | Comment |
---|---|---|---|---|---|---|
md5 | MultiTopicSavePlugin.md5 | manage | 183 bytes | 27 Jan 2016 - 02:45 | GeorgeClark | |
sha1 | MultiTopicSavePlugin.sha1 | manage | 207 bytes | 27 Jan 2016 - 02:46 | GeorgeClark | |
tgz | MultiTopicSavePlugin.tgz | manage | 90 K | 27 Jan 2016 - 02:45 | GeorgeClark | |
zip | MultiTopicSavePlugin.zip | manage | 94 K | 27 Jan 2016 - 02:44 | GeorgeClark | |
EXT | MultiTopicSavePlugin_installer | manage | 4 K | 27 Jan 2016 - 02:45 | GeorgeClark |