I want to unset some of the options in a select field of a cck form using a #pre_render function like this:


function mymodule_form_alter (&$form, $form_state, $form_id) {
	if($form_id == "stuff_node_form") {
		
	  $form['field_city']['#pre_render'] = array('mymodule_prerender');
	}
   	
}	

function mymodule_prerender($element) {
   //unset unwanted options here
}	

But I'm getting this error:

Unsupported operand types in ...drupal6/includes/common.inc on line 2727

Anyone know what's wrong with how I'm calling the #pre_render function?

Comments

mitz’s picture

You have to return the $element variable at the end of mymodule_prerender.

function mymodule_prerender($element) {
   //unset unwanted options here

  return $element;
}

I had this same issue when using the form-level pre_render command, in which case you must return the $form variable, like so:

function mymodule_prerender($form) {
   //unset unwanted options here

  return $form;  
}