You are here

public function TermsOfUseForm::buildForm in Terms of Use 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/TermsOfUseForm.php, line 40
Contains \Drupal\terms_of_use\Form\TermsOfUseForm.

Class

TermsOfUseForm

Namespace

Drupal\terms_of_use\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $config = $this
    ->config('terms_of_use.settings');

  // Adding the fieldset for node specification.
  $form['terms_of_use_text'] = array(
    '#type' => 'fieldset',
    '#prefix' => '<div id="fieldset-wrapper">',
    '#suffix' => '</div>',
  );
  $form['terms_of_use_text']['terms_of_use_node_id'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Node id where your Terms of Use are published'),
    '#default_value' => $config
      ->get('node_id'),
    '#description' => $this
      ->t('Node <em>id</em> of the page or story (or blog entry or book page) where your Terms of Use are published.'),
  );

  /*$form['terms_of_use_text']['terms_of_use_node_title'] = array(
      '#type' => 'textfield',
      '#title' => $this->t('Title of the post where your Terms of Use are published'),
      '#default_value' => $config->get('node_title')),
      '#description' => $this->t('Node <em>title</em> of the page or story (or blog entry or book page) where your Terms of Use are published.'),
      '#autocomplete_route_name' => 'terms_of_use.autocomplete',
    );
    $form['terms_of_use_text']['terms_of_use_pick_node_id'] = array(
      '#type' => 'button',
      '#value' => $this->t('I prefer to specify the node id'),
      '#weight' => 10,
      '#ajax' => array(
        'callback' => '::js',
        'wrapper' => 'fieldset-wrapper',
      ),
    );*/

  // Adding the fieldset for form specification.
  $form['terms_of_use_form'] = array(
    '#type' => 'fieldset',
  );
  $form['terms_of_use_form']['terms_of_use_fieldset_name'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label for the fieldset'),
    '#default_value' => $config
      ->get('fieldset_name'),
    '#description' => $this
      ->t('The text for the Terms of Use and the [x] checkbox are contained in a fieldset. Type here the title for that fieldset.'),
  );
  $form['terms_of_use_form']['terms_of_use_checkbox_label'] = array(
    '#type' => 'textfield',
    '#title' => $this
      ->t('Label for the checkbox'),
    '#default_value' => $config
      ->get('checkbox_label'),
    '#description' => $this
      ->t('Type here something like "I agree with these terms." or "I CERTIFY THAT I AM OVER THE AGE OF 18 YEARS OLD.", without quotes. You can use the token @link to insert a link to the Terms in this label. For example, the label can be: "I agree with the @link.", without quotes. You may want to link to the Terms if you prefer not to show the full text of the Terms in the registration form. If you use the token, the Terms will not be shown.'),
  );
  return parent::buildForm($form, $form_state);
}