You are here

function contact_ajax_contact_form_form_builder in Contact ajax 8

Entity builder for the contact form edit form with third party options.

See also

contact_ajax_test_form_contact_form_edit_form_alter()

1 string reference to 'contact_ajax_contact_form_form_builder'
contact_ajax_form_contact_form_form_alter in ./contact_ajax.module
Implements hook_form_FORM_ID_alter() for contact_form_form().

File

./contact_ajax.module, line 161
Overrides core contact form functionality

Code

function contact_ajax_contact_form_form_builder($entity_type, ContactFormInterface $contact_form, &$form, FormStateInterface $form_state) {
  $contact_form
    ->setThirdPartySetting('contact_ajax', 'enabled', $form_state
    ->getValue('contact_ajax_enabled'));
  $contact_form
    ->setThirdPartySetting('contact_ajax', 'prefix_id', $form_state
    ->getValue('contact_ajax_prefix_id'));
  $contact_form
    ->setThirdPartySetting('contact_ajax', 'render_selector', $form_state
    ->getValue('contact_ajax_render_selector'));

  // Get the confirmation type.
  $confirmation_type = $form_state
    ->getValue('contact_ajax_confirmation_type');
  $contact_form
    ->setThirdPartySetting('contact_ajax', 'confirmation_type', $confirmation_type);
  switch ($confirmation_type) {
    case CONTACT_AJAX_LOAD_FROM_URI:
      $contact_form
        ->setThirdPartySetting('contact_ajax', 'load_from_uri', $form_state
        ->getValue('contact_ajax_load_from_uri'));
      break;
    case CONTACT_AJAX_LOAD_FROM_MESSAGE:
      $contact_form
        ->setThirdPartySetting('contact_ajax', 'load_from_message', $form_state
        ->getValue('contact_ajax_load_from_message'));
      break;
    case CONTACT_AJAX_LOAD_CLEAN_FORM:
      $contact_form
        ->setThirdPartySetting('contact_ajax', 'load_clean_form', $form_state
        ->getValue('contact_ajax_load_clean_form'));
      break;
  }
}