Problem with checkboxes

A multipurpose module, plugin and component

Problem with checkboxes

New postby [email protected] » Fri Jul 01, 2011 11:30 pm

Hi,

I've created a update form with several fields, radio button groups and checkbox groups.

I run this form throught the Jumi application Manager (link to the php file with COM_JUMI_PATHNAME) and a joomla menu link.

All my fields are populated with the data which are stored in my MySql Database except those of the checkbox groups (imploded values in field languages for example).

I tried this form outside Jumi and it worked, the checkbox groups were also populated (please see code below).

Do someone have a solution to this issue ?

Thanks in advance,

Cheers Bill

Code: Select all
<?php
// AFFICHAGE DES CASES A COCHER DU CHAMP "LANGUAGES" ("LANGUAGES")
$languages=array();
$query = sprintf("SELECT languages FROM doo_call_competences WHERE id = 1", GetSQLValueString($colname_r_lst_callcompetences, "int"));
$result=mysql_query($query) or die(mysql_error());
$row=mysql_fetch_assoc($result);
$languages_ex=explode(';',$row['languages']);
foreach ($languages_ex as $val){

    if ($val !='' && is_numeric($val))       
       $languages[$val]='checked';}
       
function languages_checked($value)
{   
   global $languages;   
    if (isset($languages[$value]))       
    return 'checked';
        else       
        return '';
}
?>
<?php
echo "<pre>";
print_r($languages_ex);
echo "</pre>";
?>
         <td class="fieldtitle">Langues</td>
            <td class="fieldspacer"></td>
            <td class="fieldcontentwidth; checkbox"><input type="checkbox" name="languages[]" value="1" <?php echo languages_checked('1');?> />français
<input type="checkbox" name="languages[]" value="2" <?php echo languages_checked('2');?> />anglais
<input type="checkbox" name="languages[]" value="3" <?php echo languages_checked('3');?> />espagnol</td>
            </tr>
[email protected]
 
Posts: 4
Joined: Mon Jun 13, 2011 10:40 pm

Re: Problem with checkboxes

New postby Simon » Wed Jul 13, 2011 10:11 pm

Hi

There is an issue in your script.
You must specify $languages as global variable.
Add the row
Code: Select all
global $languages;
before it's declaration.
User avatar
Simon
Site Admin
 
Posts: 1306
Joined: Wed Jul 13, 2011 8:53 pm


Return to Jumi

Who is online

Users browsing this forum: No registered users and 5 guests

cron