function yamlform_update_8003 in YAML Form 8
Issue #2705859 Allow form elements to define custom display formats. Add emptu formats to yamlform.settings.yml.
File
- includes/
yamlform.update.inc, line 85 - YAML Form module update hooks.
Code
function yamlform_update_8003(&$sandbox) {
/** @var \Drupal\yamlform\YamlFormElementManagerInterface $element_manager */
$element_manager = \Drupal::service('plugin.manager.yamlform.element');
$element_plugins = $element_manager
->getInstances();
$format = [];
foreach ($element_plugins as $element_id => $element_plugin) {
$formats = $element_plugin
->getFormats();
if (empty($formats)) {
continue;
}
if (count($formats) == 1 && isset($formats['value'])) {
continue;
}
$format[$element_id] = '';
}
$settings_config = \Drupal::configFactory()
->getEditable('yamlform.settings');
$settings_config
->set('format', $format);
$settings_config
->save();
}