[development] Problem with hook_form_alter: Cannot unset string offsets
    Steve Ringwood 
    nevets at tds.net
       
    Mon Jun 28 14:57:36 UTC 2010
    
    
  
Whats the value of $var?
Because it's a CCK field you may need to use
$form[$var]['#type'] =  'hidden';
$form[$var]['#value'] = $nid;
to avoid clearing elements CCK expects to find.
(Side note: I would use 'value' instead of 'hidden')
Nevets
On 6/28/2010 9:46 AM, Jeff Greenberg wrote:
>
> Hi. I am hooking a node form. The content type has a  cck node 
> reference field, and the form has a text field to select the node. In 
> some cases, the user should not be allowed to select...the value 
> should be forced. So I decide which field name to use based on the 
> content type, and then change the text field to a hidden field like this:
>
>
>         $form[$var] = array(
>
>         '#type' => 'hidden',
>         '#value' => $nid,
>         );
>
>
> The form comes up just fine. The problem is, when it is submitted, I 
> receive:
>
>
> *Fatal error*: Cannot unset string offsets in 
> *sites\all\modules\cck\content.module* on line *1248*
>
>
> Thanks,
>
> Jeff
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.drupal.org/pipermail/development/attachments/20100628/409943dd/attachment.html 
    
    
More information about the development
mailing list