You are here

public function YamlForm::deleteElement in YAML Form 8

Remove an element.

Parameters

string $key: The element's key.

Overrides YamlFormInterface::deleteElement

File

src/Entity/YamlForm.php, line 996

Class

YamlForm
Defines the form entity.

Namespace

Drupal\yamlform\Entity

Code

public function deleteElement($key) {

  // Delete element from the elements render array.
  $elements = $this
    ->getElementsDecoded();
  $sub_element_keys = $this
    ->deleteElementRecursive($elements, $key);
  $this
    ->setElements($elements);

  // Delete submission element key data.
  \Drupal::database()
    ->delete('yamlform_submission_data')
    ->condition('yamlform_id', $this
    ->id())
    ->condition('name', $sub_element_keys, 'IN')
    ->execute();
}