Hi,
Arrange fields working well, but this annoying message keeps popping up,

Notice: Array to string conversion in arrange_fields_form_alter() (line 1201 of /var/www/html/sites/all/modules/arrange_fields/arrange_fields.module).

I patched the issue with this :

$string = implode($form["#attributes"]["class"]);
$form["#attributes"]["class"] = $string . " arrange-fields-container "; ##1201: arrange_fields.module
$form["#attributes"]["class"] .= " arrange-fields-container-$fid ";

this may be related to hierarchical_select, as I am using that module, but this modification seems to have done the trick, for now, Im sure there is a more elegant way of doing the same thing, but this got rid of the array to string conversion.
thanks

Comments

richardp’s picture

Thanks for the tip. Yeah, it's probably that the other module you mentioned is doing something to the array which my module isn't expecting.

Thanks for your code sample.

As I'm sure you know (but I'll comment on anyway for others), you could always lower the PHP error reporting level, since "notice" messages aren't really errors or even warnings-- just messages to the programmer to let them know about possible typos or other mistakes in code. Drupal 6 used to lower the error reporting level for you to not show notices, but they took it out in 7.

Anyway, thanks again
Richard

deepbluesolutions’s picture

Hi Richard

Im still having this issue with this module, had to patch again after last update, are there implications for making this change in the module?

regards
Daren

Ole Martin’s picture

deepbluesolutions:
I also have this error. Where should I add the code? Can you give more detailed info about this?

kenrbnsn’s picture

I got this notice at line 1258 of the current released module. That line is

$form["#attributes"]["class"] .= " arrange-fields-container ";

The code assumes that $form["#attributes"]["class"] is a string, but (at least in my case) it's an array (with one element in it), which is the reason for the notice.

I fixed the issue by replacing lines 1258 & 1259 in arrange_fields.module with

if (is_array($form["#attributes"]["class"])) {
    $form["#attributes"]["class"][0] .= " arrange-fields-container ";
    $form["#attributes"]["class"][0] .= " arrange-fields-container-$fid ";
} else {
    $form["#attributes"]["class"] .= " arrange-fields-container ";
    $form["#attributes"]["class"] .= " arrange-fields-container-$fid ";
}

These lines could be further consolidated by doing:

if (is_array($form["#attributes"]["class"])) {
    $form["#attributes"]["class"][0] .= " arrange-fields-container arrange-fields-container-$fid ";
} else {
    $form["#attributes"]["class"] .= " arrange-fields-container arrange-fields-container-$fid ";
}

This really should be submitted as a patch and fully tested.

Ken

jojojibba’s picture

Ken,
I replaced 1258 and 1259 with your consolidated patch lines and it worked wonderfully.
Thank you for this!
John

funkatron101’s picture

Priority: Normal » Major

I made the suggestion per Ken, but not I am getting this error.

Notice: Undefined index: #attributes in arrange_fields_form_alter() (line 1258 of /home/content/71/10383771/html/sites/all/modules/arrange_fields/arrange_fields.module).
Notice: Undefined index: #attributes in arrange_fields_form_alter() (line 1261 of /home/content/71/10383771/html/sites/all/modules/arrange_fields/arrange_fields.module).
Notice: Undefined index: class in arrange_fields_form_alter() (line 1261 of /home/content/71/10383771/html/sites/all/modules/arrange_fields/arrange_fields.module).

It's happening in the account access form.

richardp’s picture

Version: 7.x-1.7 » 7.x-1.11
Priority: Major » Normal
Status: Active » Fixed

Okay, I have rolled these changes into a new version -- 7.x-1.11.

For those interested, I have also added an experimental new feature, on the settings page, for allowing fields to be snapped to the grid when resizing.

Thanks for your help on this one, Ken.

Richard

funkatron101’s picture

The update worked great! The warnings are gone!

Thanks

richardp’s picture

Sure thing. On the arrange form itself, there is a button at the top which says "reset position data" or something to that effect. That will revert your form to its default state. Do NOT click the Save button after that. You can just leave the page, and your form will be displayed however Drupal would normally display it (w/o the Arrange Fields module)

Status: Fixed » Closed (fixed)

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