YamlFormElement.php in YAML Form 8
File
src/Plugin/YamlFormElement/YamlFormElement.php
View source
<?php
namespace Drupal\yamlform\Plugin\YamlFormElement;
use Drupal\Core\Form\FormStateInterface;
use Drupal\yamlform\YamlFormElementBase;
use Drupal\Core\Url as UrlGenerator;
class YamlFormElement extends YamlFormElementBase {
public function getDefaultProperties() {
return [];
}
public function form(array $form, FormStateInterface $form_state) {
$form['general'] = [
'#type' => 'details',
'#title' => $this
->t('General settings'),
'#open' => TRUE,
];
return $form;
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$form = parent::buildConfigurationForm($form, $form_state);
$form['custom']['#title'] = $this
->t('Element settings');
$form['custom']['custom']['#title'] = $this
->t('Properties');
$theme = isset($this->configuration['#theme']) ? $this->configuration['#theme'] : '';
if (function_exists('template_preprocess_' . $theme)) {
$t_args = [
':href' => UrlGenerator::fromUri('https://api.drupal.org/api/drupal/core!includes!theme.inc/function/template_preprocess_' . $theme)
->toString(),
'%label' => $theme,
];
$form['custom']['#description'] = $this
->t('Read the the %label template\'s <a href=":href">API documentation</a>.', $t_args);
}
return $form;
}
public function getElementSelectorOptions(array $element) {
return [];
}
}