2

I could make some requited cck fields "not required" by hook_form_alter a below but this doesn't work for date field.

for selection type

function hook_form_alter(&$form, &$form_state, $form_id) {
$form['field_smaple_1']['#required'] = 0; 
}

or

for text are type

function hook_form_alter(&$form, &$form_state, $form_id) {
$form['field_sample_2']['0']['#required'] = '';
}

How can I do the same thing for date field?

2

To alter date field required to disable, you can use following snippet in your form alter

$form['#field_info']['field_date']['required']=0; //field_date use your field name
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.