When adding a boolean field to a content-type, I get the following errors:

    *  Notice: Undefined index: default_value_function in cck_default_value_form()  (line 100 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: field_name in cck_field_set_setting() (line 237 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: field_name in cck_field_set_setting() (line 257 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: default_value_widget in cck_default_value_validate() (line 156 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: default_value_function in cck_default_value_validate() (line 157 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined variable: instance in cck_default_value_validate() (line 165 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined variable: langcode in cck_default_value_validate() (line 165 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: field_name in cck_field_set_setting() (line 237 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).
    * Notice: Undefined index: field_name in cck_field_set_setting() (line 257 of /Users/renelle/workspace/d7/sites/all/modules/cck/cck.module).

(fresh download of drupal-7.x-dev & cck-7.x-2.x-dev 5/3/10)

Comments

copyhold’s picture

Same error when setting default value function to any field type.
Also default_value_function value not saved.

tobiasb’s picture

Status: Active » Needs review
Issue tags: +d7sc
StatusFileSize
new7.93 KB
neopoet’s picture

Thanks -- this solves my problem as well.

droplet’s picture

Status: Needs review » Reviewed & tested by the community

the patch working well.

jzornig’s picture

The patch didn't apply neatly on the current dev version, but after applying it manually it works for me.

droplet’s picture

Status: Reviewed & tested by the community » Needs work
derjochenmeyer’s picture

Patch does not apply and can't be applied manually to current dev

das-peter’s picture

Status: Needs work » Needs review
StatusFileSize
new3.27 KB

@tobiasb Thanks for the patch :)

I've rerolled it against latest HEAD. Should work again.

MrPhilbert’s picture

Same issue here. The above file is a diff file? I've use patch files but not a diff file. Will this be added to dev?

das-peter’s picture

@MrPhilbert: You should be able to use the .diff file as patch - it's just a file naming "issue".

rfay’s picture

Issue tags: +dcsprint5

subscribe

yched’s picture

+++ cck.module
@@ -97,7 +97,7 @@ function cck_allowed_values_form(&$form, $form_state, $field) {
-  $default_value_function = $instance['settings']['default_value_function'];
+  $default_value_function = isset($instance['default_value_function']) ? $instance['default_value_function'] : '';

Incorrect. The value lies in $instance['settings']['default_value_function'], and Field API normally takes care of always populating the entry.

+++ cck.module
@@ -135,8 +135,8 @@ function cck_default_value_form(&$form, $form_state, $field) {
+  $field = isset($form['#field']) ? $form['#field'] : field_info_field($form['field']['field_name']['#value']);

$form['#field'] should also always be present.
If it's not, something is seriously wrong and should be fixed upstream, we don't want to hide that under the carpet and pretend it didn't happen.

More generally, we do not sprinkle code with random isset's all over the place.
I'm won't fixing this as is stands now. If there are actual reported warnings, with line numbers and steps to reproduce, let's investigate them one by one in dedicated issues..

Powered by Dreditor.

yched’s picture

Status: Needs review » Closed (won't fix)

As per #12

rfay’s picture

Title: "Undefined Index" errors when creating a boolean field » Allowed value and default value settings are not properly saved
Status: Closed (won't fix) » Needs work

I think this is in fact a single issue that has to be resolved, so I'm going to reopen with your permission.

How to recreate: Visit any edit or form settings form for a select-type field, configure, and submit. There is a set of problems: Some field values are not saved (as can be viewed in the cck_field_settings table). And some accessed array indexes do not exist, for related reasons, resulting in the OP report.

Many of the problems here are because these forms are injected on both the edit (instance) and the field settings tabs/forms.

$form['#field'] should also always be present.
If it's not, something is seriously wrong and should be fixed upstream, we don't want to hide that under the carpet and pretend it didn't happen.

$form['#field'] and $form['#instance'] are set on the "edit" (instance) tab, but they are not set on the field settings tab.

I'm close to a patch for your review, but don't want to lose this information.

yched’s picture

Status: Needs work » Fixed
StatusFileSize
new8.72 KB

That code needed some love :-). Warnings indeed, plus didn't actually work.

Committed the attached patch, which should fix the issues.

rfay’s picture

Thanks so much. I actually worked on it quite a bit on the plane, but didn't get far enough to post :-) It's downright hard to get your head into that stuff. Glad your head's in it.

yched’s picture

Well, FWIW, now that we have a clearer view on what's left in the CCK project in D7 (that is : the migration code...), I'd say the code that currently lies in cck.module (providing the 'php default value' / 'php allowed values' that didn't make it in core) would be better off in a separate project, field_php_values or something.

rfay’s picture

I gave this a test spin and it seems fine to me. Thanks for doing this!

karens’s picture

Yep, if anyone would like to take over that code, it's all yours :) Initially there were a number of things that didn't make it into core that needed to be handled, but we're down to just that one thing, so it really does make more sense to move it out into its own project.

Status: Fixed » Closed (fixed)

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