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)

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

tostinni’s picture

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

The problem is in code like this:

  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).

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

  //or something like that:
  if (strlen($line = trim($line)) != 0) {
joep.hendrix’s picture

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.

LAsan’s picture

Version: 5.1 » 7.x-dev

Any news about this?

clarkburbidge’s picture

Version: 7.x-dev » 6.8

I have just run into this issue on 6.8 using the profiles module. I need to have the number zero be an option for a select list. When I go to the user profile, the zero is not an option and the options in the select list starts with the number 1.

Damien Tournoud’s picture

Version: 6.8 » 7.x-dev

This looks like a confirmed bug. Any solution will need to go in 7.x first, before being backported to any other affected versions.

dawehner’s picture

Status: Active » Postponed (maintainer needs more info)

what about a wrapper called

<?php
function drupal_trim($string, $charlist = " \t\n\r\x0B") {
  return trim($string, $charlist);
}
?>

or just call trim with the changed charlist, but i guess there a quite some places, where "0" should be displayed too

sun.core’s picture

Status: Postponed (maintainer needs more info) » Active

That faulty status made each and everyone skip this issue.

Alex Savin’s picture

Title: List selection in profile will not allow a 0 value as the first item » Any field in profile will not allow a 0 value
Version: 7.x-dev » 6.15
Priority: Normal » Critical
Issue tags: +profile

I ran into this bug too and I think it should be a critical one because it really takes you the ability to insert values into a certain profile field. The problem occurs even if the type of field is textfield.

Alex Savin’s picture

Version: 6.15 » 6.x-dev
Status: Active » Needs review
FileSize
1.21 KB

For me at least, the attached patch did the job.

Alex Savin’s picture

Title: Any field in profile will not allow a 0 value » Any field in profile will not display a 0 value

I will have to correct this comment. It does insert the value "0" in the data base but it doesn't show it in any views because in the IF statement it's value is just passed like:

if($variable)
  print $variable;

instead of

if(isset($variable))
  print $variable;

Status: Needs review » Needs work

The last submitted patch, profile.patch, failed testing.

Alex Savin’s picture

Assigned: Unassigned » Alex Savin
FileSize
3.26 KB

This should do the work hopefully.

Alex Savin’s picture

Status: Needs work » Active
Alex Savin’s picture

Status: Active » Needs work
Alex Savin’s picture

Status: Needs work » Needs review
FileSize
3.26 KB

Sorry for the repeated status changes and patch attach but I think now it is better.

thedavidmeister’s picture

Version: 6.x-dev » 7.x-dev
Assigned: Alex Savin » Unassigned
Issue summary: View changes
Status: Needs review » Needs work

As per #5, any fix needs to go in the latest version of Drupal affected and then back-ported from there.

mgifford’s picture

@thedavidmeister - any reason you didn't set this to 8.x?

Alex Savin’s picture

@thedavidmeister I attached a rough patch for D7. If it passes the tests it should work fine.

dcam’s picture

@mgifford
Profile was deprecated in 7.x and only included as an upgrade path from 6.x. It was removed in 8.x See https://www.drupal.org/node/874026.

dcam’s picture

Status: Needs work » Needs review
Issue tags: -profile

I didn't notice that the last patch wasn't tested. Setting status.

mgifford’s picture

Good to know, thanks!

thedavidmeister’s picture

@dcam is correct. There is no profile module in d8.

cilefen’s picture

Priority: Critical » Major
Status: Needs review » Needs work
Issue tags: +Needs steps to reproduce

I tried but I can't reproduce this on 7.x-dev as I understand it. Could someone update the issue summary with the steps to reproduce this on Drupal 7? According to the current issue summary there is a workaround, so is this is major priority according to the guide. To be critical it would "Render the system unusable and have no workaround", which is not the case.