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(
CommentFileSizeAuthor
#2 mutual_credit-2818833-2.patch908 bytespifagor
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

m0ray79 created an issue. See original summary.

pifagor’s picture

Status: Active » Needs review
FileSize
908 bytes

above code patch failed to apply. added work patch.

matslats’s picture

Status: Needs review » Fixed

super thanks!

m0ray79’s picture

Sorry, guys, I'm really a newbie in all this "git" stuff.

matslats’s picture

I pushed the changes to HEAD

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

pifagor’s picture