[SOLVED] Checkbox values is not saved when edit
Posted: Mon Aug 27, 2007 12:57 am
I've installed the Company Directory module in CMSMS 1.1 but has encountered a problem;
I have a list of companies and a list of categories. When i want to edit a company no values in the category checkboxes is checked even though i checked one category or more when i added the company. If i look in the source code for the edit page i can see a value assigned to the correct checkbox, but there is no checked="checked" so values doesn't get saved on submit unless i check the correct categories one more time!
I've tried to look through action.editcompany.php and found this code snippet there looks like it has to do with setting the values for categories. I've tried to set a variable with checked="checked" in the CreateInputCheckbox. It sets all category checkboxes to checked in admin, so it at least tells me i found the correct code to change - but the question is what to change and how?
Oh and i guess the same problem goes for Field Definitions if whose is added to The Company Directory!
TIA
Finn
I have a list of companies and a list of categories. When i want to edit a company no values in the category checkboxes is checked even though i checked one category or more when i added the company. If i look in the source code for the edit page i can see a value assigned to the correct checkbox, but there is no checked="checked" so values doesn't get saved on submit unless i check the correct categories one more time!
I've tried to look through action.editcompany.php and found this code snippet there looks like it has to do with setting the values for categories. I've tried to set a variable with checked="checked" in the CreateInputCheckbox. It sets all category checkboxes to checked in admin, so it at least tells me i found the correct code to change - but the question is what to change and how?
Oh and i guess the same problem goes for Field Definitions if whose is added to The Company Directory!
Code: Select all
$categories = $this->GetCategoriesForCompany($compid);
$catarray = array();
if (count($categories) > 0)
{
foreach ($categories as $fielddef)
{
$field = new stdClass();
$value = '';
if (isset($fielddef->value))
{
$value = $fielddef->value;
}
if (isset($_REQUEST[$id.'category']))
{
if (isset($_REQUEST[$id.'category']['id-'.$fielddef->id]))
$value = 'true';
else
$value = 'false';
}
$field->id = $fielddef->id;
$field->name = $fielddef->name;
$field->checkbox = $this->CreateInputCheckbox($id, 'category[id-'.$fielddef->id.']', $value, 'true');
$catarray[] = $field;
}
}
Finn