View Issue Details

IDProjectCategoryView StatusLast Update
0004215phpList 3 applicationInterface - Frontendpublic18-02-08 14:08
Reportercolinangel Assigned To 
Status resolvedResolutionfixed 
Product Version2.10.2 
Target Version2.10.7Fixed in Version2.10.5 
Summary0004215: Default values for radio buttons in attributes not honored
DescriptionWhen using attributes, if a default value for a radio button is set, the subscription form does not actually default to the value specified.

The code from admin/subscribelib2.php uses "isset", but the variables being checked are ALWAYS set to 0, so the final "default" clause of the IF statement never takes effect.

if (isset($_POST[$fieldname]))
  $checked = $_POST[$fieldname] == $value["id"] ? "checked":"";
else if (isset($data[$attr["id"]]))
  $checked = $data[$attr["id"]] == $value["id"] ? "checked":"";
  $checked = $attr["default_value"] == $value["name"] ? "checked":"";
TagsNo tags attached.


related to 0003721 closed phplist 2.10.x 



25-03-06 10:34

reporter   ~0011780

One way to fix it is to make the following changes in admin/subscribelib2.php,

search for all three instances of:
if (isset($_POST[$fieldname]))
and replace them with:
if ($_POST[$fieldname] != 0)

search for all three instances of :
else if (isset($data[$attr["id"]]))
and replace them with:
else if ($data[$attr["id"]] != "")

it can be seen that only a few lines before this code, there is a check to see whether the two variables are not set, and if so to set them. this then breaks the code immediately below!

the other way to fix it therefore would be to remove that code and then make any necessary changes to the following code that is affected. the above solution is much simpler.


25-03-06 10:35

reporter   ~0011781

this is also a problem for check box groups and drop down lists. the above solution fixes these too.


12-08-07 02:16

manager   ~0030384

This issue may need reviewing as it has been raised again for ver. 2.10.4. See this forum thread:


12-08-07 03:20

administrator   ~0030385

instead of "isset" it should use "!empty" which will evaluate to false, if the var is 0 or "", but it will not throw warnings on non-initialised variables.

in phplist a lot of code is in the form

if ($var) { something }

which for PHP is not a nice way to do it, as it has security implications, so in those cases it's better to use

if (!empty($var)) { something }

Hernan, can you check this ?


13-08-07 18:48


Yes, changed two instances of
if ($var) { something }
if (!empty($var)) { something }

For select and radio butttons.