Support from Acquia helps fund testing for Drupal Acquia logo

Comments

furamag’s picture

This is bug in includes/form.inc file. We should fix function theme_form_element_label. We need to replace

if (empty($element['#title']) && empty($element['#required'])) {

to

if (!isset($element['#title']) && $element['#title'] != '' && empty($element['#required'])) {
yched’s picture

Component: field system » forms system

Pushing to form component. There's not much we can do at the Field API level.

yched’s picture

Title: Field type List(numeric) wont display zero label » '0' as

@furamag: that fix sounds correct. Care to roll a patch ?

yched’s picture

Title: '0' as » '0' not displayed as checkbox / radios options (nor as any element #title)

Oops, posted in the middle of changing the title

ygerasimov’s picture

FileSize
637 bytes

I would change the condition to
(empty($element['#title']) && ($element['#title'] != 0) && empty($element['#required']))
as if somehow NULL value will come it also should be excluded.

Please review the patch.

What is worrying me more is rendering the field afterwards. Looks like drupal_render() not rendering properly
array('#markup' => 0). Please recheck setting the value of the field to zero and look at node view page.

ygerasimov’s picture

Status: Active » Needs review
FileSize
637 bytes

changing status to 'needs review'

furamag’s picture

Tested for Drupal7-Beta1. It works fine for latest version of Drupal 7. I manually changed includes/form.inc to fix this bug. But we need to change something in this patch to apply it automatically for Drupal7-Beta1.

marcingy’s picture

Version: 7.x-dev » 8.x-dev
Status: Needs review » Needs work

Bumping to d8

marcingy’s picture

Status: Needs work » Needs review

#6: 866292-5.patch queued for re-testing.

Status: Needs review » Needs work

The last submitted patch, 866292-5.patch, failed testing.

marcingy’s picture

Status: Needs work » Needs review
FileSize
474 bytes

Just a re-roll of patch that was rtbc.

attiks’s picture

FileSize
2.47 KB

I added a test to check if the label is rendered, be warned this is my first test for core

attiks’s picture

Status: Needs review » Reviewed & tested by the community

RTBC, because my patch only added a test, original patch is working

aspilicious’s picture

You can't mark your own patch rtbc. It would be better if we had a test only patch so we could see it is failing.

(I don't say something is wrong with your patch)

attiks’s picture

Status: Reviewed & tested by the community » Needs review

@aspilicious you're right, but since patch + test is small, I'll just change the status.

Can you mark it as RTBC, if it's checks out?

aspilicious’s picture

If you upload a test only patch I can rtbc it.

marcingy’s picture

There are some issues with the patch as is. There are missing periods at the end of comments lines

// Make sure the label is rendered

And we also add a new radio button

  'first-radio' => t('First radio'),
  'second-radio' => t('Second radio'),
  'third-radio' => t('Third radio'),
+ '0' => t('0 checkbox'),

Which isn't used in the tests and also has the wrong name.

marcingy’s picture

Status: Needs review » Needs work
marcingy’s picture

Reroll of #12 to fix above and add a test for the radio as checkbox. Also the test should be checking for a t('0') as this is the case of the problem. First patch should fail and second should pass.

attiks’s picture

Status: Needs review » Reviewed & tested by the community

@marcingy thanks you're absolutely right, if think I didn't had enough coffee this morning, patch applies cleanly and does what it's supposed todo, so I guess RTBC

sun’s picture

Status: Reviewed & tested by the community » Needs work
+++ b/includes/form.inc
@@ -3948,7 +3948,7 @@ function theme_form_element_label($variables) {
   // If title and required marker are both empty, output no label.
-  if (empty($element['#title']) && empty($element['#required'])) {
+  if (empty($element['#title']) && ($element['#title'] != 0) && empty($element['#required'])) {
     return '';
   }

The added condition somehow conflicts with the first, ultimately very hard to understand. Use the following subcondition instead:

(!isset($element['#title']) || $element['#title'] === '')

20 days to next Drupal core point release.

marcingy’s picture

Status: Needs work » Needs review
FileSize
3.02 KB

Reroll taking into account #21

attiks’s picture

Looks better and is indeed more readable

quicksketch’s picture

FileSize
3.08 KB

This cropped up in the Webform queue today: #1363788: Zero integers not exported in CSV/Exel downloads..

Reroll for the core directory move.

sun’s picture

Status: Needs review » Reviewed & tested by the community

Thanks!

catch’s picture

Version: 8.x-dev » 7.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Looks good to me. Committed/pushed to 8.x. Moving to 7.x.

quicksketch’s picture

Status: Patch (to be ported) » Needs review
FileSize
3.02 KB

Reroll for D7. Exact patch, no changes needed other than removing the /core directory.

ygerasimov’s picture

Rerolled patch to 7.x

quicksketch’s picture

Status: Needs review » Reviewed & tested by the community

Haha, well I'm guessing that I can RTBC @ygerasimov's #28. :)

Solved the problem in Webform that I was experiencing. It's a little bit weird that we're bothering to translate "0", but since this was already committed to D8 and we don't translate tests anyway, I don't think there's any need to hold this up.

webchick’s picture

Status: Reviewed & tested by the community » Fixed

Oh, silly PHP. :P

Committed and pushed to 7.x. Thanks!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

cweagans’s picture

Issue tags: +Needs backport to D7