public function GoogleAdwordsPathConfigForm::form in Google AdWords Conversion Tracking 8
Gets the actual form array to be built.
Overrides EntityForm::form
See also
\Drupal\Core\Entity\EntityForm::processForm()
\Drupal\Core\Entity\EntityForm::afterBuild()
File
- modules/
google_adwords_path/ src/ Form/ GoogleAdwordsPathConfigForm.php, line 25 - Contains Drupal\google_adwords_path\Form\GoogleAdwordsPathConfigForm.
Class
- GoogleAdwordsPathConfigForm
- Class GoogleAdwordsPathConfigForm.
Namespace
Drupal\google_adwords_path\FormCode
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
/**
* @var \Drupal\google_adwords_path\Entity\GoogleAdwordsPathConfig $path_config
*/
$path_config = $this->entity;
$form['label'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Label'),
'#maxlength' => 255,
'#default_value' => $path_config
->label(),
'#description' => $this
->t("Label for the Google AdWords Path Config."),
'#required' => TRUE,
);
$form['id'] = array(
'#type' => 'machine_name',
'#default_value' => $path_config
->id(),
'#machine_name' => array(
'exists' => '\\Drupal\\google_adwords_path\\Entity\\GoogleAdwordsPathConfig::load',
),
'#disabled' => !$path_config
->isNew(),
);
/* You will need additional form elements for your custom properties. */
$form['enabled'] = array(
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => $path_config
->get('enabled'),
);
$form['conversion_id'] = array(
'#type' => 'textfield',
'#title' => t('Conversion ID'),
'#default_value' => $path_config
->get('conversion_id'),
'#size' => 15,
'#maxlength' => 64,
'#required' => TRUE,
);
$form['language'] = array(
'#type' => 'textfield',
'#title' => t('Conversion Language'),
'#default_value' => $path_config
->get('language'),
'#size' => 15,
'#maxlength' => 64,
);
$form['format'] = array(
'#type' => 'textfield',
'#title' => t('Conversion Format'),
'#default_value' => $path_config
->get('format'),
'#size' => 15,
'#maxlength' => 64,
);
$form['colour'] = array(
'#type' => 'textfield',
'#title' => t('Conversion Colour'),
'#default_value' => $path_config
->get('colour'),
'#size' => 15,
'#maxlength' => 64,
);
$form['label'] = array(
'#type' => 'textfield',
'#title' => t('Conversion Label'),
'#default_value' => $path_config
->get('label'),
'#size' => 30,
'#maxlength' => 64,
'#required' => TRUE,
);
$form['paths'] = array(
'#type' => 'textarea',
'#title' => t('Paths'),
'#default_value' => $path_config
->get('paths'),
'#rows' => 8,
'#cols' => 128,
'#required' => TRUE,
'#description' => t('A list of paths, separated by a new line, where this conversion code should be inserted.'),
);
return $form;
}