Howdy,

I've found a bug with the filefield cck field. If you create a filefield and have it as a conditional field then make it required, even when it's condition is not met the form will fail to submit saying the field is required (i.e. fielfield is not visible, but still required).

Kind regards,
Dani

Comments

peterpoe’s picture

Component: Code » Compatibility w/ other modules
Status: Active » Postponed

Postponing like all issues related to compatibility with other modules.

peterpoe’s picture

Title: Filefield bug, if set to required, it is always needed even when the condition does not display it. » Compatibility with Filefield module
Version: 6.x-1.x-dev » 6.x-2.x-dev
Status: Postponed » Active
sgerbino’s picture

Temporary workaround: Remove require from the fields in question, add a custom module to do your own validation.

function hook_form_alter(&$form, &$form_state, $form_id) {
  if(isset($form['#node']->type)) {
    switch($form['#node']->type) {
      case 'your_node':
        $form['#validate'][] = 'magical_form_validate';
        break;
    } 
  }
}

function magical_form_validate($form, &$form_state) { 
  if(is_array($form_state['values']['field_frame_upload_one'])) {
    if(!$form_state['values']['field_frame_upload_one'][0]['fid']) {
      form_set_error('field_frame_upload_one', 'You must upload one image for this frame configuration');
    }
  }
  if(is_array($form_state['values']['field_frame_upload_two'])) {
    if(!$form_state['values']['field_frame_upload_two'][0]['fid']) {
      form_set_error('field_frame_upload_two', 'You must upload two images for this frame configuration');
    }
    if(!$form_state['values']['field_frame_upload_two'][1]['fid']) {
      form_set_error('field_frame_upload_two', 'You must upload two images for this frame configuration');
    }
  }
  if(is_array($form_state['values']['field_frame_upload_three'])) {
    if(!$form_state['values']['field_frame_upload_three'][0]['fid']) {
      form_set_error('field_frame_upload_three', 'You must upload three images for this frame configuration');
    }
    if(!$form_state['values']['field_frame_upload_three'][1]['fid']) {
      form_set_error('field_frame_upload_three', 'You must upload three images for this frame configuration');
    }
    if(!$form_state['values']['field_frame_upload_three'][2]['fid']) {
      form_set_error('field_frame_upload_three', 'You must upload three images for this frame configuration');
    }
  }
}
peterpoe’s picture

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.