public function TermsOfUseForm::js in Terms of Use 8
Menu callback for AHAH addition.
File
- src/
Form/ TermsOfUseForm.php, line 156 - Contains \Drupal\terms_of_use\Form\TermsOfUseForm.
Class
Namespace
Drupal\terms_of_use\FormCode
public function js(array &$form, FormStateInterface $form_state) {
$config = $this
->config('terms_of_use.settings');
if (isset($form['terms_of_use_text']['terms_of_use_node_title'])) {
// Create the extra field.
$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.'),
);
unset($form['terms_of_use_text']['terms_of_use_node_title']);
$form['terms_of_use_text']['terms_of_use_pick_node_id']['#value'] = $this
->t('I prefer to provide the title of the post');
}
else {
// Create the extra field.
$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' => 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',
);
unset($form['terms_of_use_text']['terms_of_use_node_id']);
$form['terms_of_use_text']['terms_of_use_pick_node_id']['#value'] = $this
->t('I prefer to specify the node id');
}
// Return the form.
// @todo: Resolve the bug when user click node_id button and then cannot return back to node_title field.
return $form['terms_of_use_text'];
}