Radicore Forum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » RADICORE » How To » drop-down (drop-down)
drop-down [message #2547] Tue, 15 June 2010 14:37 Go to next message
vidhu is currently offline  vidhu
Messages: 14
Registered: February 2010
Location: SURINAME
Junior Member

Hello Sir
I have a problem in function _cm_getValRep
i have a table A and it contain composite primarykey.
And it is also foreigen key for another table B.How can i make dropdown for compositekey
Re: drop-down [message #2548 is a reply to message #2547] Wed, 16 June 2010 03:55 Go to previous messageGo to next message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
The ValRep array that is used to build a dropdown list or radio group is a simple associative array made up of value=representation pairs, where 'value' is the internal value used by the system, and 'representation' is a description which can be shown in the user's language of choice.

This means that the 'value' part can be used to look up a database record via its primary key. If this is a composite key, then the 'value' string must contain every part of this composite. You can do this by constructing a string in the format 'part1/part2/part3' where '/' is a separator which does not appear in any of the parts. Once the user has chosen a value you will then have to split out the parts before performing the database lookup.


Re: drop-down [message #2549 is a reply to message #2548] Wed, 16 June 2010 08:11 Go to previous messageGo to next message
vidhu is currently offline  vidhu
Messages: 14
Registered: February 2010
Location: SURINAME
Junior Member

HELLO SIR
thanks for your kind information.Could you give me an
example

[Updated on: Wed, 16 June 2010 08:40]

Report message to a moderator

Re: drop-down [message #2550 is a reply to message #2549] Wed, 16 June 2010 08:52 Go to previous message
AJM is currently offline  AJM
Messages: 2368
Registered: April 2006
Location: Surrey, UK
Senior Member
Here is an example of how to build a ValRep array with composite keys:
$this->sql_select     = 'part1, part2, description';
$this->sql_orderby    = 'part1, part2';
$this->sql_ordery_seq = 'asc';
$data = $this->getData(null);

// convert each row into 'id=desc' in the output array
foreach ($data as $row => $rowdata) {
    $key = $rowdata['part1].'/'.$rowdata['part2'];
    $array[$key] = $rowdata['description'];
} // foreach

return $array;

Note here that each key string is in the format 'part1/part2' with '/' as the separator. When the selected key is sent in via the $_POST array you have to split this single string field back into its component parts.


Previous Topic: Filter records based on user
Next Topic: list2
Goto Forum:
  


Current Time: Sun Nov 24 06:23:30 EST 2024

Total time taken to generate the page: 0.01476 seconds