You are here

function quiz_form_field_config_edit_form_alter in Quiz 8.6

Same name and namespace in other branches
  1. 8.5 quiz.module \quiz_form_field_config_edit_form_alter()
  2. 6.x quiz.module \quiz_form_field_config_edit_form_alter()

Implements hook_form_FORM_ID_alter().

Adds a checkbox for controlling field edit access to fields added to quizzes.

File

./quiz.module, line 774
Contains quiz.module

Code

function quiz_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {
  $field = $form_state
    ->getFormObject()
    ->getEntity();
  if ($field
    ->getTargetEntityTypeId() != 'quiz_result') {
    return;
  }
  $form['third_party_settings']['quiz']['show_field'] = array(
    '#type' => 'checkbox',
    '#title' => t('Show this field on @quiz start.', array(
      '@quiz' => _quiz_get_quiz_name(),
    )),
    '#default_value' => $field
      ->getThirdPartySetting('quiz', 'show_field', TRUE),
    '#description' => t('If checked, this field will be presented when starting a quiz.'),
  );
}