When I try to create a new text field for a content created using cck field, I am getting this warning warning: Invalid argument supplied for foreach() in F:\Program Files\Apache Group\Apache2\htdocs\drupal-5.0\sites\all\modules\cck\text.module on line 328.

Comments

yched’s picture

I can't seem to reproduce.
The $item variable in text.module line 328 should always be an array.

Can you provide more info on your config (PHP version, MySQL version)
and on your field (which widget, which settings ?)

poldrack’s picture

I get the warning to. My php und mysql-version is:

MySQL-Datenbank 4.1.15
PHP 5.2.0

yched’s picture

Well, I can't reproduce with PHP 5.1 (I do not have a 5.2 test environment)
Can both of you provide an output of your content type (using "export" tab - requires enabling content-copy.module) ?

Is text the only field type which triggers this ?

BioALIEN’s picture

Just happened to me too - using the current CCK 1.3

Only seems to be doing it to text.module - I will do further investigations to check if anything else is causing this or try and narrow it down somehow.

yched’s picture

As I wrote earlier, pasting an export of your content type may help :-)

BioALIEN’s picture

Sorry for the delay, here's the info you requested - its a complete export of the node type that was causing the problem. Some information about my setup:
Drupal 5.1
PHP 5.2.0
MySQL database 5.0.27
Web server Apache/2.2.3 (Unix) mod_ssl/2.2.3 OpenSSL/0.9.8d DAV/2 PHP/5.2.0

$content[type]  = array (
  'name' => 'Notice',
  'type' => 'notice',
  'description' => 'A page for notice board related content.',
  'title_label' => 'Title',
  'body_label' => 'Body',
  'min_word_count' => '0',
  'help' => 'Submit notices to the Notice board.',
  'node_options' => 
  array (
    'status' => true,
    'promote' => false,
    'sticky' => false,
    'revision' => false,
  ),
  'comment' => '0',
  'upload' => '0',
  'old_type' => 'notice',
  'orig_type' => '',
  'module' => 'node',
  'custom' => '1',
  'modified' => '1',
  'locked' => '0',
);
$content[fields]  = array (
  0 => 
  array (
    'widget_type' => 'image',
    'label' => 'Image',
    'weight' => '0',
    'max_resolution' => 0,
    'image_path' => 'notices',
    'custom_alt' => 0,
    'custom_title' => 0,
    'description' => '',
    'group' => false,
    'required' => '1',
    'multiple' => '0',
    'field_name' => 'field_image',
    'field_type' => 'image',
    'module' => 'imagefield',
  ),
  1 => 
  array (
    'widget_type' => 'text',
    'label' => 'Name',
    'weight' => '1',
    'rows' => '1',
    'description' => 'Name of the person',
    'field_name' => 'field_name',
    'default_value_php' => '',
    'group' => false,
    'required' => '1',
    'multiple' => '0',
    'text_processing' => '0',
    'max_length' => '',
    'allowed_values' => '',
    'allowed_values_php' => '',
    'field_type' => 'text',
    'module' => 'text',
  ),
);
sentinelcz’s picture

Version: 5.x-1.3 » 5.x-1.4
Component: General » text.module
Assigned: Unassigned » sentinelcz

I try edit text file. This message appears. Note:
If I start update script, this message appears too..
warning: Invalid argument supplied for foreach() in \modules\cck\text.module on line 327.
warning: Invalid argument supplied for foreach() in \modules\cck\text.module on line 124.
Strange is If I try to fill new content, I have in “name” default value “f”.
Of course I haven’t set any default value in text field.
Next others text fields are without problem.

I am using
Apache: 2.0.59
PHP 5.2.1
MySql 5.0.27
Firefox 2.0.0.2

Export

$content[type] = array (
'name' => 'Acc Template',
'type' => 'acc_template',
'description' => 'Here you can fill new acc',
'title_label' => 'title field',
'body_label' => '',
'min_word_count' => '0',
'help' => 'Please fill all items carefully.',
'node_options' =>
array (
'status' => true,
'promote' => true,
'sticky' => false,
'revision' => false,
),
'comment' => '2',
'old_type' => 'acc_template',
'orig_type' => '',
'module' => 'node',
'custom' => '1',
'modified' => '1',
'locked' => '0',
);
$content[fields] = array (
0 =>
array (
'widget_type' => 'text',
'label' => 'Name',
'weight' => '0',
'rows' => '1',
'description' => 'You can fill maximum 40 characters.',
'field_name' => 'field_name',
'default_value_php' => '',
'group' => 'group_address',
'required' => '1',
'multiple' => '0',
'text_processing' => '0',
'max_length' => '40',
'allowed_values' => '',
'allowed_values_php' => '',
'field_type' => 'text',
'module' => 'text',
'default_value' => 'field_name',
),
);

BioALIEN’s picture

Strange is If I try to fill new content, I have in “name” default value “f”.

I also got this from my testing in #6.

jimyhuang’s picture

I found the bug.
If the label set to "name", than the $items infomations will loss when 'process form values' (line 325)

sentinelcz’s picture

Great, thank you. Question is if this bug will be correct.

BioALIEN’s picture

I think jimyhuang is right. Both of these error cases use "name". Maybe it should be stated in advance during the widget creation screen so people are aware of these "reserved named"?

This would fix the issue by design!

yched’s picture

Title: Invalid arguement error while creating CCK textfield » default values conflict when field label = 'name'
Component: text.module » General

Oooh. Nice catch. This is vicious.

This is related to the 'default value' widget in the field setting form.
It adds a field_(FIELD_NAME) form element, which of course conflicts with the regular 'field_name' element when FIELD_NAME == 'name' ...
This is most probably not restricted to text fields.

Unfortunately I'm under a pressing deadline, so I'm not really sure how this can be fixed right now.
Ugly workaround for now :
- _create_ your field with a name that is not 'name'
- later on, change the label (does not affect the machine-readable field name)

yched’s picture

Status: Active » Fixed

OK, turns out the fix was rather simple after all - you guys probably had more work pinning this down to 'name' labels. Thanks all.

Should be fixed in latest (pre 1.5) 1.x-dev code

For once, a bug specific to anglophone users :-)

Anonymous’s picture

Status: Fixed » Closed (fixed)