public function GoogleAnalyticsAdminSettingsForm::addOne in Google Analytics 4.x
Submit handler for the "add-one-more" button.
Increments the max counter and causes a rebuild.
File
- src/
Form/ GoogleAnalyticsAdminSettingsForm.php, line 1156
Class
- GoogleAnalyticsAdminSettingsForm
- Configure Google_Analytics settings for this site.
Namespace
Drupal\google_analytics\FormCode
public function addOne(array &$form, FormStateInterface $form_state) {
$id_field = $form_state
->get('id_count');
$add_button = $id_field + 1;
$form_state
->set('id_count', $add_button);
// Since our buildForm() method relies on the value of 'num_names' to
// generate 'gtag_id' form elements, we have to tell the form to rebuild. If we
// don't do this, the form builder will not call buildForm().
$form_state
->setRebuild();
}