rename #multiple to #cardinality in field forms

yched - June 20, 2009 - 22:39
Project:Drupal
Version:7.x-dev
Component:field system
Category:bug report
Priority:critical
Assigned:Unassigned
Status:closed
Issue tags:Fields in Core
Description

#multiple matched $field['multiple'] in D6, which has become $field['cardinality']

#1

yched - June 20, 2009 - 22:58

Side note: should be super easy for a Field API novice.

#2

tstoeckler - June 22, 2009 - 14:58
Assigned to:Anonymous» tstoeckler

Will have a go at this tomorrow!

#3

tstoeckler - June 27, 2009 - 16:19
Assigned to:tstoeckler» Anonymous

Well, tomorrow is gone by now. I'm still on this, theoretically, but my network driver has crapped on my linux system, so I'm back to Windows until that is fixed. Shouldn' take me more than a few days nonetheless. Still, if someone beats me to it, I wouldn't be mad.

#4

dakala - September 20, 2009 - 06:17
Assigned to:Anonymous» dakala

I'd like to give this a go, please:-)

#5

dakala - September 21, 2009 - 11:34

Please be gentle, it's my first attempt at creating a patch for core. Only a few occurrences remain but hey, who cares? A patch is a patch:-)

AttachmentSizeStatusTest resultOperations
field.attach.inc_.patch780 bytesIdlePassed: 13470 passes, 0 fails, 0 exceptionsView details | Re-test
field.form_.inc_.patch1.23 KBIdlePassed: 13465 passes, 0 fails, 0 exceptionsView details | Re-test

#6

bjaspan - September 21, 2009 - 12:35
Status:active» needs work

dakala, thanks for taking this on!

Please read http://drupal.org/patch for instructions about how to create core patches for Drupal. Proper patches make reviewing easier, allow the test bot to work, and make it possible to commit the patch when it is ready.

#7

dakala - September 21, 2009 - 20:38

Thanks bjaspan. Here's what I've done - updated my working copy of files, checked my changes and ran cvs diff from the root directory. Here's the output.

AttachmentSizeStatusTest resultOperations
rename-multiple-to-cardinality-497504-7.patch2.18 KBIdleFailed: Invalid PHP syntax in modules/field/field.form.inc.View details | Re-test

#8

yched - September 23, 2009 - 19:16

Patch looks great, thanks dakala ! I would have expected there would be more ocurrences to replace, but I'm not where I can check myself. Please make sure you did a search / replace on the whole of core.

#9

dakala - September 23, 2009 - 19:39

I'll do a search on the whole of core and not only the field modules as the issue affects all forms indeed. Then, I'll re-roll the patch.

#10

dakala - September 23, 2009 - 20:23

There's loads more occurrences of #multiple and they've all been replaced. The new patch is attached. Thanks.

AttachmentSizeStatusTest resultOperations
rename-multiple-to-cardinality-497504-10.patch17.24 KBIdlePassed: 13462 passes, 0 fails, 0 exceptionsView details | Re-test

#11

yched - September 24, 2009 - 13:33

Er, my awful bad :-), most core occurrences of #multiple in core should remain #multiple.
AAMOF, only the field.attach.inc and field.form.inc hunks are valid changes - er, those are the ones in your patch #7...)

I'm not completely sure about the options.module changes. We do need to keep '#multiple' => at the left of => assignments, but the $element['#muliple'] we read is probably the property renamed to #cardinality in field.form.inc. Would need some manual testing...

#12

bjaspan - September 24, 2009 - 16:36

@dakala, yeah, yched gave you bad advice. Go easy on him, he's on vacation. :-)

You need to distinguish between #multiple for Form API (which should stay) and #multiple for Field API (which should change to #cardinality). So your patch in #7 may be right. I'll re-attach it here and set CNR to see what hte testbot thinks.

AttachmentSizeStatusTest resultOperations
rename-multiple-to-cardinality-497504-7.patch2.18 KBIdlePassed: 13468 passes, 0 fails, 0 exceptionsView details | Re-test

#13

bjaspan - September 24, 2009 - 16:36
Status:needs work» needs review

forgot to change status

#14

dakala - September 29, 2009 - 00:59

@bjaspan, @yched: Thanks guys. Actually, there were a few obvious places I'd left out and I suspected there was something going on between FAPI and Field API that I didn't understand. Thanks for the clarification.

#15

Dries - September 29, 2009 - 01:08
Status:needs review» fixed

Makes sense. Committed.

#16

yched - September 29, 2009 - 11:25
Priority:minor» critical
Status:fixed» active

Cool, thanks dakala !

Not where I can test, as bjaspan explained in #12 :-p, but I'd say option.module needs some changes too. The #multiple boolean set on select dropdowns, or the fact we chose radios or checkboxes, should depend on #cardinality.

Thus now raising to critical, because I suspect option.module is currently broken

#17

dakala - September 29, 2009 - 19:50

Ok. I'll look into getting that sorted right away.

#18

dakala - October 2, 2009 - 10:09

@yched: Maybe this should wait till you're able to check?

The 2 functions (options_buttons_elements_process() and options_select_elements_process() in options.module) dealing with #multiple/cardinality seem okay to me. In order to set the #multiple boolean, the ternary expressions check for $element['#multiple'] before $field['cardinality'].

#19

bjaspan - October 15, 2009 - 23:03
Assigned to:dakala» Anonymous

@dakala: Your help on this issue has been great and very much appreciated... Thanks!

However, the remaining issue of fixing #multiple vs. #cardinality in exactly the right places is frankly not a Field API novice job. In fact I think yched is probably the only person that knows the right answer. Even if you submitted a patch, I wouldn't really know how to verify it is correct.

There are tests for option.widgets now that make it seem they are working, so this can probably wait until yched gets back from vacation, or at least clues me in here about how to understand #multiple vs. #cardinality in these forms. :-)

#20

yched - November 11, 2009 - 23:56
Status:active» fixed

Getting back late here.
My bad, I was on crack in #16, everything is at it should. Thanks again, dakala.

#21

System Message - November 26, 2009 - 00:00
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.