Hi Mantainers,

I testet user read_only module in a client website and got a fatal cannot use string as an array error. The user wantet to change the contact settings in their account (this field was not user read_only protectet) but the array $form[$group][$key]['#attributes']['disabled'] = TRUE; could not be managed by drupal.

Quick and dirty solution is just to comment that line out (//). Problem you lose the hidden field, no gray in the backround any more. I will try to fix this, but any help is god because i´m to busy with more impotant stuff.

Dirk

CommentFileSizeAuthor
#4 contrib-5.user_readonly.error_.junyor.patch681 bytesjunyor

Comments

jaydub’s picture

I can't totally confirm this fix and I haven't been able to recreate the bug but what I did notice when testing is that the error occurs when the value for $group in the

foreach ($form as $group => $data) {

part of the code that surrounds the offending line 208 had a value of of '#name' where name
was something I can't recall. I wrapped the test in line 191 with a regex test to see if $group
matches the #xxxx name. So

if (!array_key_exists($key,$field_list)) {

becomes

if ( (!array_key_exists($key,$field_list)) || (preg_match("/^#/",$group)) ) {

designwork’s picture

Hi jaydub,

i will test it today, thanks

Dirk

jbrauer’s picture

I just ran into this today and made the change suggested by jdub in #1 and it worked well on our site.

junyor’s picture

Status: Active » Needs review
StatusFileSize
new681 bytes

This happens if the form has top-level stuff like #parameters and/or #attributes. Attached is a patch that fixes the issue. The fix is similar to the one suggested by jaydub, but the check was moved earlier to save some processing.

deekayen’s picture

Status: Needs review » Fixed

committed

Anonymous’s picture

Status: Fixed » Closed (fixed)

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