SID-01487: Access the $formfield of a child through a %SEARCH%
| Status: |
Answered |
TWiki version: |
4.1.2 |
Perl version: |
|
| Category: |
|
Server OS: |
|
Last update: |
13 years ago |
Hello,
I have a database of vehicles. I have cars and engines that are in the database. I have an engine as a child of a car. I have a %TABLE% that I am populating using %SEARCH% to search for cars and $formfield to find the specific field I want. I would like to also pull some $formfield data from the child engine of the cars that are being searched. I can't hardcode the child $formfield because there are multiple cars that have engines and each car may/may not have an engine.
I am able to %SEARCH% for the engines and pull the parent $formfield data but this technique generates some problems that I would rather not deal with.
Any help is appreciated
--
JohnRuiz - 2012-06-13
Discussion and Answer
You can use
VarFORMFIELD. Say you have an engine XYZ with 2000 CC. To query the CC, use
%FORMFIELD{ "CC" topic="XYZ" }%. To query this in a SEARCH format you need to escape the variable:
format="| ....| $percntFORMFIELD{ \"CC\" topic=\"$formfield(Engine)\" } |"
You could also check if the Engine form field is set using an escaped
VarIF. However, and empty
topic="" in FORMFIELD will default to the current topic (the one of the query). Since that topic has no form field called CC it will show nothing, which is likely what you want. So ou can simply ignore the empty field case.
--
PeterThoeny - 2012-06-18
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.