SID-02106: Populate Form with links issued from a Search
| Status: |
Answered |
TWiki version: |
6.0.1 |
Perl version: |
5 |
| Category: |
CategoryForms |
Server OS: |
RedHat |
Last update: |
10 years ago |
Hi all.
I am working on my knowledge base and I am stuck with an improvement I want to make.
First, my knowledge base is set up as this support web : topics are created with a pre-defined name, for example
KmPrj00001 for a project or
KmLes00001 for a lesson learned.. ect the proper name is defined in the formfield "Name"
Right now when the user want to create a lesson learned, he has to fill in a text box for the projects linked to that lesson.
What I am trying to do is:
1- propose a list (using the intelligible name from formfield "Name") from a search of all projects for the user to pick in the creation process
2- pass to the form a link to that project : something like
[[KmPrj00001][ formfield "Name"]
What I have done :
1- I managed to have my form looked at the list of project in the form of links :
| !Project | select+multi | 10 | %SEARCH{ search="^KmPrj[0-9]+" nonoise="on" order="%URLPARAM{ "order" default="modified" }%" reverse="%URLPARAM{ "reverse" default="on" }%" scope="topic" type="regex" format=" [[$topic][$formfield(Name)]]," }% Other to be created! | Project concerned | |
2- using
VarEDITFORMFIELD, I then loose the link and then it doesn't match the form...
I wonder if it is not the good way to do it.. but the good thing is when you edit the topic you can choose from the different links.
I tried another way bay passing the link from the creation page :
Project during which we learned a lesson%BR%<select name="test1"><option>%URLPARAM{"test1"}%</option><option>%SEARCH{ search="^KmPrj[0-9]+" nonoise="on" order="%URLPARAM{ "order" default="modified" }%" reverse="%URLPARAM{ "reverse" default="on" }%" scope="topic" type="regex" format="<option > $formfield(Name) </option>" }% <option>Other to be created!</option></select>
<input type="hidden" name="Project" value="%URLPARAM{ "test1" default="nothing" }%" />
it is not working either.
Any suggestions?
--
Sebastien Digard - 2015-09-29
Discussion and Answer
Not sure I understand your question, but it looks like you want a dropdown where the submitted value is different from the displayed value.
1. If you use a TWiki Form and want to present to the user this dropdown, use type
select+multi+values. Details at
TWikiForms
2. You can create a hand-crafted HTML form with a dropdown:
<select name="Project">
<option value="">Select...<option>
%SEARCH{
search="^KmPrj[0-9]+"
nonoise="on"
order="%URLPARAM{ "order" default="modified" }%"
reverse="%URLPARAM{ "reverse" default="on" }%"
scope="topic"
type="regex"
format="<option value=\"$topic\">$formfield(Name)</option>"
}%
</select>
--
Peter Thoeny - 2015-09-29
Thanks Peter,
the hand-crafted HTML is close to what I need. I want the value to be a link to the topic using the intelligible name. Something like :
format="<option value=\" [[$topic][$formfield(Name)]]\">$formfield(Name)</option>"
but this is not working.
--
Sebastien Digard - 2015-09-30
How about reworking the app? I think it is better not to store the full link in the form field. That way the Name field is not duplicated and can't get out of sync. Better to store just the topic name, and then in the report compose the proper link using
VarFORMFIELD to look up the Name.
--
Peter Thoeny - 2015-10-01
ok,
so i though again about it and reworked it that way :
- when the new topic is created, the user browse through a list of project using explicit names: $topictitle
- the real topic is stored in the form in the format KmPrj00...($topic)
- the header is then doing the translation into an explicit link.
There is one thing missing though: father and child handling. I want to use the parent functionality to link topics together. I just need to create a button on each topic enabling the user to change the parent from a list of $topictitle... any thoughts on how I can do that?
--
Sebastien Digard - 2015-10-04
Create a form with
action="/cgi-bin/save/Support/SID-02106" method="post" attributes, containing a select with dynamic options as discussed before. Use
name='topicparent' attribute for the select.
--
Peter Thoeny - 2015-10-04
Thanks,
I changed it to
<form name="new" action="%SCRIPTURLPATH{save}%/%BASEWEB%/%BASETOPIC%" method="post"> and now it works
--
Sebastien Digard - 2015-10-05
Indeed. better to use the SCRIPTURLPATH variable for the action attribute.
--
Peter Thoeny - 2015-10-05
If you answer a question - or someone answered one of your questions - please remember to edit the page and set the status to answered. The status selector is below the edit box.