NOTE:: Before reporting an issue, make sure you are running the latest version, currently 3.3.1

View Issue Details Jump to Notes ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004215phplist applicationInterface - Frontendpublic01-10-05 01:4518-02-08 14:08
PlatformOSOS Version
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.
Attached Files

- Relationships
related to 0003721closed phplist 2.10.x 

-  Notes
lukejackson (reporter)
25-03-06 10:34

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.
lukejackson (reporter)
25-03-06 10:35

this is also a problem for check box groups and drop down lists. the above solution fixes these too.
h2b2 (manager)
12-08-07 02:16

This issue may need reviewing as it has been raised again for ver. 2.10.4. See this forum thread: [^]
michiel (manager)
12-08-07 03:20

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.

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker