List selection in profile will not allow a 0 value as the first item

zoon_unit - March 27, 2007 - 19:58
Project:Drupal
Version:7.x-dev
Component:profile.module
Category:bug report
Priority:normal
Assigned:Unassigned
Status:active
Description

If one uses the profile module to make a list selection box that contains numbers, if the first number in the list is a zero, it will not appear as a selection. (however, listing the number as <0>, works)

#1

tostinni - May 3, 2007 - 21:19

In fact this a little worse than that, it doesn't accept 0 at all.

The problem is in code like this:

<?php
 
if ($line = trim($line)) {
?>

When line equal 0, we have if (0) which is FALSE so this value is omitted. Should we write:

I'm not sure on how to correct this (with clean code I mean).

<?php
  $line
= trim($line);
  if (!empty(
$line) || $line == '0') {

 
//or something like that:
 
if (strlen($line = trim($line)) != 0) {
?>

#2

JoepH - June 6, 2007 - 09:24

The same problem if you want to accept an empty string.
I want the first line to accept an empty string. This is specially usefull for required fields.
I want the user to select a value when it is a required field. Now the first value is automatically selected which is not correct.

#3

LAsan - March 26, 2008 - 10:41
Version:5.1» 7.x-dev

Any news about this?

 
 

Drupal is a registered trademark of Dries Buytaert.