You are here

public function CivicrmOptions::getConfigurationFormProperties in Webform CiviCRM Integration 8.5

Get an associative array of element properties from configuration webform.

Parameters

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

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

Return value

array An associative array of element properties.

Overrides WebformElementBase::getConfigurationFormProperties

File

src/Plugin/WebformElement/CivicrmOptions.php, line 136

Class

CivicrmOptions
Provides a 'civicrm_options' element.

Namespace

Drupal\webform_civicrm\Plugin\WebformElement

Code

public function getConfigurationFormProperties(array &$form, FormStateInterface $form_state) {
  $properties = parent::getConfigurationFormProperties($form, $form_state);
  if (!empty($form['properties'])) {

    // Get additional properties off of the options element.
    $select_options = $form['properties']['options']['options'];
    $properties['#default_option'] = $select_options['#default_option'];
    if (empty($properties['#default_value'])) {
      $properties['#default_value'] = $select_options['#default_option'];
    }
  }
  if (!isset($properties['#civicrm_live_options'])) {
    $properties['#civicrm_live_options'] = $form_state
      ->getValues()['civicrm_live_options'] ?? 0;
  }

  // Make sure options are available on the element.
  if (!isset($properties['#options'])) {
    $properties['#options'] = $this
      ->getFieldOptions($properties);
  }
  return $properties;
}