/
Several warnings on Contact Us form [5.2.1-RC1]

Several warnings on Contact Us form [5.2.1-RC1]

I see following warning for each field being displayed on "Contact Us" form:

Warning (#1): Field "Value" is not defined in "formflds" unit config in ...\core\kernel\kbase.php on line 849

The problem is caused by the ConfigFormElement tag used within form_field block, that is defined within /themes/advanced/platform/elements/dynamic_forms.elm.tpl template.

How it works

If form has fixed field count, then it's not a problem to hardcode all of them in template like so:

<inp2:m_RenderElement name="inp_edit_box" prefix="submission-log" field="ToEmail" size="60" title="la_fld_ToEmail"/>
<inp2:m_RenderElement name="inp_edit_box" prefix="submission-log" field="Cc" size="60" title="la_fld_Cc"/> 

However, when form field configuration is defined in the database (like "Custom Fields" or "Contact Us forms"), then it's no longer seems that easy. The ConfigFormElement comes to rescue, because it can (when executed for each form field) determine which block needs to be used to render a particular field. For example:

<inp2:ConfigFormElement field="Value" blocks_prefix="form_field_" element_type_field="ElementType" value_list_field="ValueList" /> 

In this case final block name to be rendered is combined of 2 parts:

  • blocks_prefix tag parameter value, which is form_field_ in this case
  • element type name, which is read from field name (ElementType in this example) specified inelement_type_field tag param (e.g. "checkbox", "radio", "text")

Then the final block name to render can be form_field_checkbox.

Current usage

Presently tag is used in 3 places:

  • on the configuration screens (e.g. on "Configuration > Website > Advanced" section in Admin Console)
  • during custom field entry (e.g. on category/product editing screens in Admin Console)
  • during Contact Us form display (both Front-End and Admin Console)

Problem

Note the field parameter in the ConfigFormElement tag. Here is how it works:

  1. the given field (the Value in this case) is virtual
  2. field is populated from the PrintList tag with the value of printed field on a particular form
  3. then ConfigFormElement sets different field properties (e.g. list of possible options) to allow correct rendering on a page
  4. then field value is displayed using regular Field or PredefinedOptions tag located in form_field_* blocks

This works perfectly for configuration screens and custom fields, however when dealing with "Contact Us forms" a bit different approach is taken. In fact we only require part of tag where it guesses block name to be rendered. The actual value of a field is retrieved directly from associated object, that holds all the data via SubmissionTag tag.

Because of it we don't have any Value field to set options to and we got that Warning.

Solution

I propose, that we just create virtual Value field, so that we won't get any warnings. This field will never be used, except for ConfigFormElement tag.

missing_value_field_contact_us_fix.patch

Related Discussions

Related Tasks

INP-1377 - Getting issue details... STATUS