You are here

function invite_migrate_form_validate in Invite 7.4

Implements validation for migration form.

_state

Parameters

$form:

File

includes/invite.admin.inc, line 444

Code

function invite_migrate_form_validate($form, &$form_state) {
  if ($form_state['values']['type'] == 'none') {
    form_set_error('type', t('Please choose an Invite type.'));
  }
  else {

    // TODO: add field mapping to the form.
    $needed_fields = array(
      'field_invitation_email_address',
      'field_invitation_email_subject',
      'field_invitation_email_body',
    );
    $verified_fields = 0;
    foreach (field_info_instances('invite', 'invite_by_email') as $field_name => $field) {
      if (in_array($field_name, $needed_fields)) {
        $verified_fields++;
      }
    }
    if ($verified_fields != count($needed_fields)) {
      form_set_error('type', t('This content type couldn\'t be used.'));
    }
  }
}