How to use form.handle in Custom field.html I've created a custom field.html which is working fine when I manually specify the formHandle for use with submittedEntry as mentioned in the docs:

{% set ourForm = craft.sproutForms.form('formHandle') %}
{% set submittedEntry = craft.sproutForms.getEntry(ourForm) %}


However, I need to be able to have a dynamic formHandle in the field.html as I am using the same file for an infinite number of forms. This means I cannot manually specify the formHandle as it throws the below error (as the form methods for Form A won't exist in Form B)

Craft\SproutForms_EntryModel and its behaviors do not have a method or closure named "fieldNameFormB".




Is there any way I can pass form.handle from form.html into field.html so that I can use the below code, or is there another method by which I'm not forced to manually specify the form?

{% set ourForm = craft.sproutForms.form(form.handle) %}
{% set submittedEntry = craft.sproutForms.getEntry(ourForm) %}
I have updated the plugin files to make this work as I needed it to.

In sproutforms/variables/SproutFormsVariables.php, I have updated the $bodyHtml variable at Line 57 to include handle =&gt; $formHandle

$bodyHtml = craft()-&gt;templates-&gt;render(
    'tab', array(
        'handle'               =&gt; $formHandle,
        'tabs'                 =&gt; $form-&gt;getFieldLayout()-&gt;getTabs(),
        'entry'                =&gt; $entry,
        'formFields'           =&gt; $fields,
        'thirdPartySubmission' =&gt; !!$form-&gt;submitAction,
        'displaySectionTitles' =&gt; $form-&gt;displaySectionTitles,
        'renderingOptions'     =&gt; $renderingOptions
    )
); 


This means in my Template Override in _forms/tabs.html I can pass the handle as a variable

{%- if formField -%}
    {% include "field" with {
        form:                 handle,
        field:                field,
        element:              entry,
        required:             required,
        formField:            formField,
        renderingOptions:     renderingOptions,
        thirdPartySubmission: thirdPartySubmission,
    } only %}
{%- endif %}  


I can then do as I required with not needing to specifically specify a form name in my submittedEntry variable

{% set ourForm = craft.sproutForms.form(form) %}
{% set submittedEntry = craft.sproutForms.getEntry(ourForm) %}




The use case for this update is if clients can add forms through the Matrix, you need to get form.handle in submittedEntry so that you can populate the form post using value="{{ attribute(submittedEntry, fieldName) }} if the form fails validation (so that the form doesn't return empty on validation failure).

In the documentation the submittedEntry value is always manually set, however in this example you need to be able to set submittedEntry dynamically so that you can use generic Template Overrides in _forms rather than having overrides per form in _forms/formHandle.