- 🇨🇦Canada joelpittet Vancouver
joelpittet → changed the visibility of the branch 8.x-1.x to hidden.
- 🇨🇦Canada joelpittet Vancouver
The reroll is quite tricky because the logic for yaml creation changed... I am moving this back
Hi everybody,
After a lot of migrate test, I discover a little missing feature.
By default, with multiple condition on a field, it's the logical "AND" which is applied. But on my D7 Webform I have logical "or", which is not supported yet.
Have a field with multiple conditions but, only one of these conditions could be TRUE to display the field (OR). It's just an example.
My solution is maybe a little ugly, I'm open to suggestion to improve this code.
They'r 2 steps, first in build the condition and second, write states in yaml file:
if (!$unsupported_condition) {
// Add indicator that we are a logical 'or' condition
if($condition['andor'] == 'or'){
$states[$element_state][] = [
':input[name="' . $depedent['form_key'] . '"]' => [
'element' => $element_condition,
'logical' => 'or'
]
];
}else{
// Actual building condition (AND is the default, so we don't need to specify)
$states[$element_state][] = [':input[name="' . $depedent['form_key'] . '"]' => $element_condition];
}
In second time :
if($item['logical'] === 'or'){
$markup .= "$indent " . str_replace("\n","",Yaml::dump([$name], 4, 2)). ":\n";
foreach (explode("\n", Yaml::dump($item['element'], 2, 2)) as $line) {
$markup .= "$indent " . $line. "\n";
}
$markup .= "$indent " . Yaml::dump(['or'], 4, 2);// . "\n";
}
else{
// Actual yaml write condition
$markup .= "$indent " . Yaml::dump($name, 2, 2) . ":\n";
foreach (explode("\n", Yaml::dump($item, 2, 2)) as $line) {
$markup .= "$indent " . $line. "\n";
}
}
Yes, it's not very beautiful but it's the only way that I am found to write yaml like this
- ':input[name="23_1_nouvelle_raison_sociale"]':
filled: true
- or
- ':input[name="23_1_nouveau_numeros_de_siret"]':
filled: true
- or
- ':input[name="23_1_nouveau_code_ape"]':
filled: true
- or
- ':input[name="nouvelle_ccn"]':
filled: true
instead of this
':input[name="23_1_nouvelle_raison_sociale"]':
filled: true
or
':input[name="23_1_nouveau_numeros_de_siret"]':
filled: true
or
:input[name="23_1_nouveau_code_ape"]':
filled: true
or
':input[name="nouvelle_ccn"]':
filled: true
Which is not working and through a yaml parser error by the way.
Again, if it can be improve it will be nice. Furthermore I haven't add the XOR logical, but I believe it wasn't possible in D7 webform, but Im'n not sure.
Have a nice day :-)
Needs work
2.0
Code
The patch will have to be re-rolled with new suggestions/changes described in the comments in the issue.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.
joelpittet → changed the visibility of the branch 8.x-1.x to hidden.
The reroll is quite tricky because the logic for yaml creation changed... I am moving this back