function yamlform_update_8010 in YAML Form 8
Issue #2712463: Provide Entity–attribute–value model for submissions. Remove #default_value target_id.
File
- includes/
yamlform.update.inc, line 263 - YAML Form module update hooks.
Code
function yamlform_update_8010() {
$ids = [];
$config_factory = \Drupal::configFactory();
foreach ($config_factory
->listAll('yamlform.yamlform.') as $yamlform_config_name) {
$yamlform_config = $config_factory
->getEditable($yamlform_config_name);
$inputs = $yamlform_config
->get('inputs');
if (preg_match('/-\\s+target_id:/', $inputs)) {
// Have to regex to replace inputs target_id: in YAML because if we parse
// the inputs YAML all comments and formatting will be lost.
$inputs = preg_replace('/-\\s+target_id: /', '- ', $inputs);
$yamlform_config
->set('inputs', $inputs);
$yamlform_config
->save(TRUE);
$ids[] = $yamlform_config
->get('id');
}
}
if ($ids) {
return t('Updated forms: @ids', [
'@ids' => implode(', ', array_unique($ids)),
]);
}
}