I have some require fields in some form,I want them be required in somewhere and in another place not be required (I want exactly them , maybe you suggest me use existance field in cck but this fields not in cck.)
I used profile2 module with some profile type, I want in profile type edit page as example name field be required and in user registration name field not be required.
I try to alter #require property of name field in form alter, it's changed correctly but in validation tell me the name field is required.
in
function mymodule_form_alter(&$form,&$form_state) {
if ($form_id == 'user_register_form') {
$form['profile_detailp']['field_name']['und']['#required']=0;
...
}
}
any idea ?
Your method is ok, and have to works but maybe in another module it
requireagain.