Hi,

I'm making progress with writing my module, but have hit a snag on a password_confirm form item. I when entering a password of less than 4 characters, I get "warning: Invalid argument supplied for foreach() in /var/www/grumbler/includes/form.inc on line 762." and nothing else. It doesn't get into the submit subroutine. Otherwise, I'd see the changed variables rendered in the updated form.

The whole page isn't much more code than this at the moment, so I'm positive there isn't some other code screwing up the page.

I think I'm not using the API right. But I'm not clear where I'm going wrong.

//typical drupal code goes here for help/menu, etc.

//this loads the ajaxy password changing features
module_load_include('module', 'user');

function grum_master_check_password($element, $form_state) {
if (strlen($element) < 4) {
	form_error($element, t('Password must be longer than 4 characters.'));
	};
}

//the sub that gives me ajaxy password goodness.
_user_password_dynamic_validation();
$form['grumbler_master_pwd2'] = array(
	'#type' => 'password_confirm',
//	'#title' => 'Confirm Password',
	'#access' => 'access grumbler server',
	'#element_validate' => 'grum_master_check_password($element, $form_state)',
	'#size' => 30,
	);

$form['submit'] = array(
	'#type' => 'submit', 
	'#value' => t('Update SuperUser'),
	'#submit' => 'grum_master_change_superuser($server_control, $element)',
	);


Comments

ww9rivers’s picture

Try this:

'#element_validate' => array('grum_master_check_password');