0

I've made a custom module for Drupal 6 that has a custom form, which works perfectly.

I've tried to add the form in a block using the following code.

function mymodule_block($op = 'list', $delta = 0, $edit = array()) {
    switch ($op) {
       case 'list':
          $blocks[0]['info'] = t('BLOCK INFO');
          return $blocks;
       case 'view':
          $blocks['content'] = drupal_get_form('mymodule_form');
          return $blocks;
   }
}

I can see the block in the admin page, and I can move the block to the different regions and everything seems to work, except for a list of warnings I get every time I change the region of the block.

warning: Illegal string offset 'region' in block\block.admin.inc on line 101.
warning: Illegal string offset 'status' in block\block.admin.inc on line 101.
warning: Illegal string offset 'status' in block\block.admin.inc on line 102.
warning: Illegal string offset 'weight' in block\block.admin.inc on line 103.

How can I fix these warnings?

I think these warnings happen because block.admin.inc is trying to access a non existent key ("region", "status"...etc). How can I remove said warnings? I have looked into some threads but their solutions have not worked for me.

  • For one thing in your view case you need to be checking delta (in your case you are using delta = 0). See the hook_block() docs example. – rooby Apr 9 '14 at 5:15
  • But I only have 1 block, so I don't think it has to do with delta. Renamed the variable "blocks" to "block" to make it more clear. – Dany Apr 9 '14 at 9:22
0

The problem was due to the PHP version being used. It seems that Drupal 6 has some problems with PHP 5.4.

  • @Bala actually it does. If OP says that problem was created by certain PHP version, then it is the answer, no matter how strange or unuseful it might be. – Mołot Apr 9 '14 at 11:06
0

Here is the patch page:

https://www.drupal.org/node/1680614

"The problem seems to be that block_admin_display_form_submit() handler is just looping through all the form values assuming each value is a valid block settings form array() and when it hits fields relating to the buttons and form ID then it errors because it is not an array." #6

There is a bug, but you see the error in PHP 5.4.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.