You are here

public function Create::submitForm in SimpleAds 8

Same name in this branch
  1. 8 src/Form/Groups/Create.php \Drupal\simpleads\Form\Groups\Create::submitForm()
  2. 8 src/Form/Ads/Create.php \Drupal\simpleads\Form\Ads\Create::submitForm()
  3. 8 src/Form/Campaigns/Create.php \Drupal\simpleads\Form\Campaigns\Create::submitForm()

Form submission handler.

Parameters

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

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

Overrides FormInterface::submitForm

File

src/Form/Campaigns/Create.php, line 78

Class

Create
New advertisement campaign form.

Namespace

Drupal\simpleads\Form\Campaigns

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $campaigns = new Campaigns();
  $type = $form_state
    ->getValue('campaign_type');
  $options = [];
  $options = $campaigns
    ->getSubmitForm('create', $options, $form_state, $type);
  $campaigns
    ->setCampaignName($form_state
    ->getValue('name'))
    ->setDescription($form_state
    ->getValue('description'))
    ->setType($type)
    ->setOptions($options)
    ->setStatus($form_state
    ->getValue('status'))
    ->save();
  $form_state
    ->setRedirect('simpleads.campaigns');
}