First of all, excuse my English.

I have a little testing site with Drupal 6.20 + CCK 3.0-alpha1 installed. I have made a custom node type for culinary recipes. This type includes optional multigroup Masterclass, which consist of two CCK fields: ImageField and TextArea, both marked as "required'.

Expected behaviour: user can fill optional master-class in recipe; in this case both fields of every subgroup of master-class must be filled. Or user can ignore master-class at all and leave it empty.

Actual behaviour: if master-class is not filled, user cannot save new node because of error: "Field required and must be filled" (actually another text in Russian but with the same meaning). And this error mention ImageField only, not a TextArea. The order of fields plays no role, only ImageField refered in the error.

Now I have to clear 'required' checkbox on ImageField field, but it definitely breaks the logic of master-class creation.

So, is there any way to workaround this problem? I can make any testing needed, but unfortunately I have no practice in PHP programming. :-(

CommentFileSizeAuthor
#12 Image 1108.75 KBxarbot
#12 Image 2123.77 KBxarbot

Comments

RedRat’s picture

Title: Cannot save node with empty optional multigroup with required fields. » Cannot save node with empty non-required multigroup if it has required fields.
xarbot’s picture

I'm having the same problem. Subscribe

Xarbot

karens’s picture

Status: Active » Fixed

I think I have this fixed now.

xarbot’s picture

When i download the last alpha and upgraded i have this error

Cannot use a scalar value as an array a /SAN/ocw/sites/all/modules/cck/modules/content_multigroup/content_multigroup.node_form.inc a la línia 354.

Thanks in advanced

Xarbot

karens’s picture

Status: Fixed » Postponed (maintainer needs more info)

What kind of field do you have on your form where you see this? That message would imply you have a form that has an object where there should be an array. I need more information about this to do anything with it.

sergmain’s picture

An error 'Cannot use a scalar value as an array a /SAN/ocw/sites/all/modules/cck/modules/content_multigroup/content_multigroup.node_form.inc a la línia 354.'
completely reproducible in bug report http://drupal.org/node/1093928 with CCK 6.x-3.x-dev tar.gz 2011-Mar-16

Full error stack is
* warning: Cannot use a scalar value as an array in C:\opt\Apache2\htdocs\modules\cck\modules\content_multigroup\content_multigroup.node_form.inc on line 354.
* warning: Cannot use a scalar value as an array in C:\opt\Apache2\htdocs\modules\cck\modules\content_multigroup\content_multigroup.node_form.inc on line 354.
* warning: uasort() [function.uasort]: The argument should be an array in C:\opt\Apache2\htdocs\includes\common.inc on line 2944.

Bug report http://drupal.org/node/1094490 related to this issue too.

karens’s picture

Status: Postponed (maintainer needs more info) » Fixed

Fixed this issue. Looking at the others.

xarbot’s picture

Hello:
I don't have this bug. But now when i select only field required of the multigroup, all the fields in the multigroups apeears as required.

Thanks in advanced

Xarbto

RedRat’s picture

Status: Fixed » Active

After upgrading to alpha2 I have got this error:

warning: Cannot use a scalar value as an array in /arc/www/drupal/sites/all/modules/cck/modules/content_multigroup/content_multigroup.node_form.inc on line 354.

warning: uasort() expects parameter 1 to be array, boolean given in /arc/www/drupal/includes/common.inc on line 2944.

Also, creating a content type with multigroup is impossible now: I got 500 error instead and this error in the log:

[Thu Mar 17 13:48:09 2011] [error] PHP Fatal error: Unsupported operand types in /arc/www/drupal/includes/common.inc on line 2946

Do we need to reopen this issue or make a followup to http://drupal.org/node/1094490?

xarbot’s picture

Install dev version. It's applied to dev version, not to alpha

Xarbot

karens’s picture

I need more information about the bug in #8, I don't understand what you're describing.

xarbot’s picture

StatusFileSize
new123.77 KB
new108.75 KB

Ok:
Imagine you have 1 multigroup. Inside this you have 4 fields. You mark the first one as required. Then, the problem is that all fields in the group are marked as required.

See the images. In image 1 i marked only this field as required, but the forms are rendered all fields are marked as required (Image 2)

Thanks in advanced

Xarbot

RedRat’s picture

Upgraded to the latest 6.x-3.0-dev version (17 March), initial error still here: cannot save empty multigroup with image-field marked as 'required'. :-(

karens’s picture

Status: Active » Fixed

Found the problem and committed a fix. I needed to use array_keys() on the required fields list.

xarbot’s picture

Do you commited to the dev version?

I continue with the same problem in #12, but i think that the dev version is the same as 3 hours ago

Thanks in advanced!!

Xarbot

karens’s picture

Status: Fixed » Active

Re #12, imagefield had its own way of validating, had to make another fix to fool imagefield into leaving it alone for an empty group. I think empty groups with required fields are now passing through correctly.

Committed that much, now I need to test that empty required fields still get flagged as errors if the group is not empty.

karens’s picture

Status: Active » Fixed

Had to add tweak so that required imagefields get highlighted correctly if empty in a non-empty group.

As far as I can see the current state of dev is handling required fields in non-required groups correctly. I'd appreciate it if others bang that around and be sure nothing is missing. Also test required fields in required groups to be sure they still work as they should.

RedRat’s picture

Initial bug is fixed in the dev as of March, 18, so now I can save nodes with empty multigroup.

xarbot’s picture

The problem is not a imagefield field because is a file field, not imagefield field :P

I don't explain well :)

Imagine that you don't have the file field, the problem continues. When i put some field as required in multigroup all the fields in the multigroup are marked as required, and i only need only field required, not all.

Thanks in advanced

Xarbot

RedRat’s picture

To xarbot: I have a multigroup consisted of two fields: imagefield and textarea, both marked as required. A minute ago I marked textarea field as non-required, and now it appears as non-required while content creation, just as expected. Are you sure that all your other fields, except needed one, marked as non-required?

xarbot’s picture

Ok, i try with dev version of 18 March and #12 works well.

Now i have a problem with cck_scorm project.

Fatal error: Cannot use string offset as an array in /SAN/ocw/sites/all/modules/cck_scorm/SCORM_widget.inc on line 219

I push a issue in cck_scorm project too

Thanks in advanced

Xarbot

xarbot’s picture

Sorry, but now i have this error

array_keys() [function.array-keys]: The first argument should be an array a /SAN/ocw/sites/all/modules/cck/modules/content_multigroup/content_multigroup.node_form.inc a la línia 281.

i delete the cck scorm field.

Thanks in advanced

Xarbot

karens’s picture

This is not a catch-all issue for any problem you see. Please file separate reports for each issue.

If you see a problem related to some other module, start there, don't report it both here and there. If they decide it is a CCK issue they can move it back.

xarbot’s picture

Ok, sorry i open a new issue

Thanks

Xarbot

Status: Fixed » Closed (fixed)

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