I'm changing the field 'field_project' widget type in one of my sites to 'hidden' because I only have one project and users get confused on that field in the create issue form.
There is a validation hook for that field 'project_issue_field_project_validate' which is causing issues because I've changed the widget type.
I've created this path to fix the issue, so we can change between other widgets than the default 'autocomplete'

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

alexandrezia’s picture

alexandrezia’s picture

Issue summary: View changes
drumm’s picture

Status: Needs review » Needs work

There are a few places where this should follow https://drupal.org/coding-standards better:

  • Indent break; one more level.
  • Keep { on the same line.

Since $widget_type is only used once, it shouldn't be stored in a variable, just used directly in the switch condition.

Since many cases have the same code, they should be grouped together and use fall through.

formatC'vt’s picture

just like this

  switch($form_state['field']['field_project'][LANGUAGE_NONE]['instance']['widget']['type']) {
    case 'entityreference_autocomplete':
      $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $form_state['values']['field_project'][LANGUAGE_NONE][0]['target_id'];
      break;
    case 'entityreference_autocomplete_tags':
    case 'options_buttons':
    case 'options_select':
      $form_state['node']->field_project[LANGUAGE_NONE][0]['target_id'] = $form_state['values']['field_project'][LANGUAGE_NONE];
      break;
  }