[drupal-devel] [bug] form_checkboxes saves "no selection" as string

chx drupal-devel at drupal.org
Mon Mar 28 16:32:25 UTC 2005


Issue status update for http://drupal.org/node/18663

 Project:      Drupal
 Version:      cvs
 Component:    base system
 Category:     bug reports
-Priority:     critical
+Priority:     normal
-Assigned to:  chx
+Assigned to:  Anonymous
 Reported by:  killes at www.drop.org
 Updated by:   chx
-Status:       patch
+Status:       active
 Attachment:   http://drupal.org/files/issues/checkboxes_0.patch (1.71 KB)

Oh NO! One strayed space! I fixed it before steven beheads me....


chx



Previous comments:
------------------------------------------------------------------------

March 10, 2005 - 02:51 : killes at www.drop.org

If you select nothing from a set of checkboxes an empty string is save
to the variables table. This is a problem if the calling code assumes,
it would get an array.
We should make it save an empty array. The problem is the form_hidden
field that we add. even if we replace form_hidden($name, 0) by
form_hidden($name, array()) it isn't going to work, because the empty
array is eaten by htmlspecialchars.
redLED found this bug and he does not like it:
02:53 < redLED> i just like things saying 'CRITICAL' in red
02:53 < redLED> it gives this warm impending doom feeling
02:53 < redLED> and is generally associated with nuclear reactors in
people's subconsciousness
Suggestions welcome.


------------------------------------------------------------------------

March 12, 2005 - 19:47 : Steven

There is no way to fix it in form_checkboxes() itself afaik, because
even without htmlspecialchars, it would still come out as "Array". You
can only create arrays indirectly through form submissions, by naming
your values "foo[]". But you can not create empty arrays this way.
So it is really up to the module which uses form_checkboxes() to handle
this. A simple is_array() should do the trick.


------------------------------------------------------------------------

March 28, 2005 - 17:27 : chx

Attachment: http://drupal.org/files/issues/checkboxes.patch (1.71 KB)

system_settings_save can not really cope with this situation. This makes
a problem with empty node options. And the fact that we have a check
everywhere we use form_checkboxes is error prone, too. Here is a patch.
If this accepted I'll comb the core for dead code. For eg. the first
three lines of taxonomy_save_vocabulary and so.





More information about the drupal-devel mailing list