Hello

Based on the comment #1 http://drupal.org/node/356487#comment-2044356, I reopen an issue.

I've customized the default content type profile by adding a CCK image field. This field is required but during the register process this field can be left empty.

If I try to create a new content 'Profil' by the default node creation process the image field is required. This bug just come during the registration.

Comments

jepster_’s picture

Hi,

I've write a mini-module which is working for my case. maybe it helps you.


function content_profile_filefield_fix_form_alter( &$form, &$form_state, $form_id ) {
	// init validation
	$form['#validate'][]='content_profile_filefield_fix_validate';
}

function content_profile_filefield_fix_validate($form, &$form_state) {


	if(!empty($form_state['submitted']) && is_numeric(strpos($_SERVER['REQUEST_URI'], '/register'))){

		if($form_state['values']["field_perso_front"]['0']['fid'] == 0 && $form_state['values']["field_perso_back"]['0']['fid'] == 0){
			form_set_error('field_perso_front', 'Please load the pictures up and click on "register".');
			form_set_error('field_perso_back', ' ');
		} else {
			
			
			if($form_state['values']["field_perso_front"]['0']['fid'] == 0){
				form_set_error('field_perso_front', 'Please load the left picture up and click on "register".');
			}
			
			if($form_state['values']["field_perso_back"]['0']['fid'] == 0){
				form_set_error('field_perso_back', 'Please load the right picture up and click on "register".');
			}
		
		}
	}

}
stevedova’s picture

I've the same problem and i see the mini-module of jepSter, but how to use it?
Thanks

jepster_’s picture

Simply add it into your module, dump the $form_state var, to see which name your content field has and change the array-identifier inside my mini-module.

mitylite’s picture

I also have this problem, and I also am not sure exactly what to do with that code. Do we create a brand new custom module or add it into the content profIle module?