Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Go to Accounting->Transactions, switch to Form Display Control, select "Bill" or "Credit" (/admin/accounting/transactions/form-display/credit)
Change something or just save settings
An error occurs: "{{ description }} MUST appear in the Main form twig template." - but "{{ description }}" is definitely present.
The problem is in validate_twig_template() callback.
First, there is a missing space near '}}'.
Next, the validator does not check for invisible fields.
My changes are:
diff --git a/modules/forms/mcapi_forms.inc b/modules/forms/mcapi_forms.inc
index 5e2da3a..b639a1e 100644
--- a/modules/forms/mcapi_forms.inc
+++ b/modules/forms/mcapi_forms.inc
@@ -280,11 +280,12 @@ function mcapi_forms_display_submit($form, $form_state) {
function validate_twig_template(array $element, $form_state) {
$required = mcapi_forms_required_fields()[0];
+ $invisible = ['xid', 'uuid', 'serial', 'parent', 'creator', 'type', 'state', 'changed'];
$errors = [];
// Find the required field and ensure they are all here.
// Ensure the worth field is present.
- foreach (mcapi_forms_required_fields()[0] as $fieldname) {
- if (strpos($element['#value'], '{{ '.$fieldname. '}}') == NULL) {
+ foreach ($required as $fieldname) {
+ if ( (!in_array($fieldname, $invisible)) && strpos($element['#value'], '{{ '.$fieldname. ' }}') == NULL) {
$form_state->setError(
$element,
t(
Comment | File | Size | Author |
---|---|---|---|
#2 | mutual_credit-2818833-2.patch | 908 bytes | pifagor |
Comments
Comment #2
pifagorabove code patch failed to apply. added work patch.
Comment #3
matslats CreditAttribution: matslats as a volunteer commentedsuper thanks!
Comment #4
m0ray79 CreditAttribution: m0ray79 commentedSorry, guys, I'm really a newbie in all this "git" stuff.
Comment #5
matslats CreditAttribution: matslats as a volunteer commentedI pushed the changes to HEAD
Comment #7
pifagor