Hello!

Notice: Undefined offset: 1 in select_or_other_field_formatter_view() (line 451 in /sites/all/modules/select_or_other/select_or_other.field_widget.inc).
Such an error I get in dblog.
I have 4 fields with different settings in my content type, so can settings of each of them help to solve error?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

kaztur created an issue. See original summary.

legolasbo’s picture

What you can do is try to reproduce the error on a vanilla Drupal installation. Start with the select or other field, and add the other fields one by one. Note the step's you've taken until you start seeing the error. If you post these steps I can reproduce (and solve) the issue.

Zekvyrin’s picture

This can happen when displaying the value using "select or other widget":

If "Other" is not selected (and the textfield is empty) but the field has other values selected, there is an entry in the table without data (without the character '|'). But because there are data in the field, $pos returns the position of the first line and stops there.

What should be done is check the position of '|' character in every line.

I'm uploading a patch...

Zekvyrin’s picture

Version: 7.x-2.22 » 7.x-2.x-dev
Status: Active » Needs review
FileSize
1.02 KB
Zekvyrin’s picture

Sorry, forgot to close a parenthesis in previous patch.

The last submitted patch, 4: select_or_other-undefined_offset_1_in-2596057-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 5: select_or_other-undefined_offset_1_in-2596057-5.patch, failed testing.

legolasbo’s picture

@Zekvyrin,

Thanks for your interest and the patch.

That said, I think you are taking the wrong approach to solving this issue.

What should be done is check the position of '|' character in every line.

What should actually be done is the following:

  1. Prevent that a | gets saved to the db in the first place.
  2. Add a regression test
  3. Add a hook_update_n() implementation removing any wrongly stored | values from the db.
legolasbo’s picture

Status: Needs work » Postponed (maintainer needs more info)

I am unable to reproduce this issue in either 2.x or 3.x. Please provide clear steps to reproduce on vanilla Drupal.

legolasbo’s picture

Status: Postponed (maintainer needs more info) » Active

While working on something else I found how to reproduce the issue. Working on a fix.

  • legolasbo committed ce0e74f on 7.x-3.x
    Issue #2596057 by legolasbo: Undefined offset: 1 in...

  • legolasbo committed 873556d on 7.x-2.x
    Issue #2596057 by legolasbo: Undefined offset: 1 in...

  • legolasbo committed 0aa0483 on 7.x-3.x
    Improved fix of Issue #2596057: Undefined offset: 1 in...
legolasbo’s picture

Status: Active » Fixed

Fixed the issue by making sure no empty lines are saved.

  • legolasbo committed 8877575 on 7.x-3.x
    Bugfix for #2596057 - options were joined incorrectly.
    

  • legolasbo committed 71f4041 on
    Bugfix for #2596057 - options were joined incorrectly.
    

kaztur’s picture

@legolasbo, sorry, didn't have a time to test.
So, cann't follow the thread of issue (possibly because of ny bad english) - is issue fixed with module update or should I apply the patch from #5 by Zekvyrin?

legolasbo’s picture

It's fixed in the latest dev version, but there might be some regressions from other issues as I am currently rewriting the module.

Status: Fixed » Closed (fixed)

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

quimic’s picture

Component: CCK / Field API widget » Field widget (non-specific or listed)

Can we expect a 2.x release with this issue fix?