I'm trying to use the FormSelectMultiple function for one of my forms.
Could some one post an example of what kind of array it wants for the $data .
Please? :)
Thanks
Watch
GitHub Core
Show your support for Zikula! Sign up at Github account and watch the Core project!
GitHub Modules
- mesteele101 created topic »Pages 2.5.0 and updating - Page not found« 05:20 AM
- mesteele101 responded to »ERR (3): E_USER_ERROR: Smarty error: [in pagesvar:pagesitem2en line XXX]…« 05:05 AM
- mesteele101 responded to »Zikula 1.3.3 - Selecting a category in Pages not working« 01:29 AM
- mdee created topic »How to implement returnpage ?« 01:00 AM
- nestormateo responded to »Fillters in Clip« 24. May
- damon responded to »Can the Updated Version Check be Turned Off (Z 1.3)« 24. May
- frw responded to »Bug in the SMTP mail transfer protocol - Port 25 - Zikula 1.2.9« 22. May
Zikula Blog
- Anatomy of Open Source Projects on Mar 07
- Continuous Review on Mar 01
- Not Invented Here on Feb 24
- How to Contribute Your Code at Github on Jan 13
- 10 Steps to Coding-Nirvana: Tips for Successful Module Writing on Nov 12
- Submitting Bug Report Tickets That Get Results on Aug 17
- Cozi Tricks #1: Syntax Highlighting on Aug 07
Login
FormSelectMultiple
-
- Rank: Developer
- Registered: Dec 31, 1969
- Last visit: Jun 01, 2010
- Posts: 6859
see the API referecnes at http://www.c0d3.de/html
--
Home Page | Find on Facebook | Follow on Twitter
-
- Rank: Developer
- Registered: Dec 31, 1969
- Last visit: Jun 01, 2010
- Posts: 6859
pnAPI and pnHTML are both covered at that site, and pnHTML is still an API of sorts.
--
Home Page | Find on Facebook | Follow on Twitter
-
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: May 25, 2005
- Posts: 8
/* hi,my form dropdown shows nothing but, say if i have five items in myarray it will have 5 lines,just that i cant see it each element.How to make this work? */
$myarray = pnModAPIFunc('Conference','admin','userlist');
print_r($myarray);
//PRINTED THIS :
//Array ( [0] => Array ( [uname] => Anonymous ) [1] => Array ( //[uname] => radzee ) [2] => Array ( [uname] => seeker ) )
//the drop down in my form
$row[] = $output->FormSelectMultiple('allowed_user_1', $myarray, 0,1);
//this is the function for the API
function conference_adminapi_userlist()
{
$myarray = array();
$dbconn =& pnDBGetConn(true);
$pntable =& pnDBGetTables();
$userstable = $pntable['users'];
$userscolumn = &$pntable['users_column'];
$SQL = "SELECT $userscolumn[uname]
FROM $userstable
ORDER BY $userscolumn[uname]";
$result = $dbconn->Execute($SQL);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _GETFAILED);
return false;
}
for (; !$result->EOF; $result->MoveNext()) {
list($uname) = $result->fields;
$myarray[] = array('uname' => $uname);
}
$result->Close();
return $myarray;
}
//hope somebody can guide me and explain where have i gone wrong -
**unknown user**
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 1097
pnHTML is legacy code...
Give a shot to a pnRender style mod...
I also suggest that if you put only one value per array row, don't save it as an array... or save also the uid...
either
Code
$myarray[] = $uname;
}
or
Code
$sql = "SELECT $userscolumn[uid],
$userscolumn[uname]
FROM $userstable
ORDER BY $userscolumn[uname]";
$result = $dbconn->Execute($sql);
if ($dbconn->ErrorNo() != 0) {
pnSessionSetVar('errormsg', _GETFAILED);
return false;
}
for (; !$result->EOF; $result->MoveNext()) {
list($uid, $uname) = $result->fields;
$myarray[] = array('uid' => $uid,
'uname' => $uname);
}
And lastly, use the bbcode "code" tag as it makes code more readable.
-
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: May 25, 2005
- Posts: 8
Thanks for the advice chestnut,
I still have a problem with FormSelectMultiple,i've saved only uname in the array now it seems only the first letter of each element is shown in the drop down box,how to make it shown in full?
this is my form field
$row[] = $output->FormSelectMultiple('allowed_user_1', $myarray, 0, 1, $uname);
thanks again for the reply.I'll look into pnRender as soon as i finish this.
by the way,why did it work that way? -
**unknown user**
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 1097
Some correction about what I said...
Here would be the working code :
Code
or if you are using the uid...
Code
The FormSelectMultiple is looking for an id and a name...
id serves as the value of the option, name serves for the display
Code
<option value="WHAT IS IN THE ID">WHAT IS IN THE NAME</option>
Boy this is old stuff....... hard time remembering it.
-
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: May 25, 2005
- Posts: 8
:shock: glad u replied .. i dont know whether i should laugh or just kill myself LOL .. man i tried putting UID in the array and they display fine... when i changed to UNAME it shows only the first character..is it because of FormSelectMultiple only show 1 character? -
**unknown user**
- Rank: Registered User
- Registered: Mar 16, 2002
- Last visit: May 25, 2005
- Posts: 8
LOL i just asked a super dumb thing man .. it is working now ... cool dude ... thanks .. brain is not prone to details when i'm frustated i guess.
Quote
$myarray[] = array('id' => $uname,
'name' => $uname);
i get it ... formSelectMultiple needs id,name field ... :D
thanks chestnut .. problem solved -
**unknown user**
- Registered: Mar 16, 2002
- Last visit: Oct 21, 2009
- Posts: 1097
mmm....... not sure it is wise to delete the anonymous from the user table as it can be of use elsewhere and in perms but all you had to do was removing it from your query.......
Code
$sql = "SELECT $userscolumn[uid],
$userscolumn[uname]
FROM $userstable
WHERE $userscolumn[uid] != '1'
ORDER BY $userscolumn[uname]";
Anonymous user being user uid 1 if I remember correctly.
- Moderated by:
- Support
