You are here

public function Mp3playerAddForm::submitForm in MP3 Player 8

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/Mp3playerAddForm.php, line 332
Contains \Drupal\mp3player\Form\ExampleForm.

Class

Mp3playerAddForm
Implements an Mp3playerAddForm form.

Namespace

Drupal\mp3player\Form

Code

public function submitForm(array &$form, FormStateInterface $form_state) {
  $values = $form_state
    ->getValues();
  if (isset($values['pid'])) {
    $keys = array(
      'pid' => $values['pid'],
    );
  }
  else {
    $keys = array(
      'name' => $values['name'],
    );
  }
  \Drupal::database()
    ->merge('mp3player_players')
    ->key($keys)
    ->fields(array(
    'name' => $values['name'],
    'autostart' => $values['autostart'],
    'loopaudio' => $values['loopaudio'],
    'animation' => $values['animation'],
    'remaining' => $values['remaining'],
    'noinfo' => $values['noinfo'],
    'initialvolume' => $values['initialvolume'],
    'buffer' => $values['buffer'],
    'encode' => $values['encode'],
    'checkpolicy' => $values['checkpolicy'],
    'rtl' => $values['rtl'],
    'width' => $values['width'],
    'transparentpagebg' => $values['transparentpagebg'],
    'pagebg' => $values['pagebg'],
    'bg' => $values['bg'],
    'leftbg' => $values['leftbg'],
    'lefticon' => $values['lefticon'],
    'voltrack' => $values['voltrack'],
    'volslider' => $values['volslider'],
    'rightbg' => $values['rightbg'],
    'rightbghover' => $values['rightbghover'],
    'righticon' => $values['righticon'],
    'righticonhover' => $values['righticonhover'],
    'loader' => $values['loader'],
    'track' => $values['track'],
    'tracker' => $values['tracker'],
    'border' => $values['border'],
    'skip' => $values['skip'],
    'text' => $values['text'],
  ))
    ->execute();
  $form_state
    ->setRedirect('mp3player.player_list');
}