2

I'm working on a website that has a simple form consisting of an input field, where an email address can be entered, and a submit button in the footer. The button leads to a contact page with a Powermail form. The form has an input field where the value from the footer input would get carried over.

The problem I have is that I don't know how to carry over the value from the input field from one page to the input field of another. One thing I've noticed is that if the submit button has a value that it gets carried over. However, I don't know how to get the value from the input element.

Here's the footer form:

<f:form action="email" pluginName="tx_powermail_pi1" controller="Form" method="post" pageUid="26" class="uk-flex">
<div class="uk-width-1-2">
    <f:form.textfield name="tx_powermail_pi1[field][email]" value="{email}" placeholder="Your email ..." <div class="uk-width-1-2">
    <f:form.button type="submit" value="{email}" name="tx_powermail_pi1[field][email]" class="uk-button uk-button-primary button-newsletter">
        Anmelden
    </f:form.button>
</div>
<f:form.hidden value="1" name="tx_powermail_pi1[type]"/>
<f:form.hidden value="1" name="no_cache"/>
</f:form>

Here's the Powermail form from the contact site how it gets displayed on the page:

<form data-parsley-validate="data-parsley-validate" data-validate="html5" enctype="multipart/form-data" name="field" class="powermail_form powermail_form_1"
 action="/newsletter?tx_powermail_pi1%5Baction%5D=create&amp;tx_powermail_pi1%5Bcontroller%5D=Form&amp;cHash=838bac372f487bb18decb49eba8a9643#c35" method="post" novalidate="">
<fieldset class="powermail_fieldset powermail_fieldset_1 nolabel">
    …
    <div class="powermail_fieldwrap powermail_fieldwrap_type_input powermail_fieldwrap_email">
        <label for="powermail_field_email" class="powermail_label" title="">
            Email
        </label>
        <div class="powermail_field">
            <input required="required" aria-required="true"
                   data-parsley-required-message="Dieses Feld muss ausgefüllt werden!" data-parsley-trigger="change"
                   data-parsley-error-message="Keine gültige E-Mail-Adresse!" class="powermail_input"
                   id="powermail_field_email" type="email" name="tx_powermail_pi1[field][email]" value=""></div>
    </div>
    <div class="powermail_fieldwrap powermail_fieldwrap_type_submit powermail_fieldwrap_send  ">
        <div class="powermail_field "><input class="powermail_submit" type="submit" value="Absenden"></div>
    </div>
</fieldset>
<input class="powermail_form_uid" type="hidden" name="tx_powermail_pi1[mail][form]" value="1">
</form>

: The solution to this is to remove the name attribute from the submit button. The value of the input field then gets carried over to the other page.

This is how the code looks like now:

<f:form action="email" pluginName="tx_powermail_pi1" controller="Form" method="post"
        pageUid="26" class="uk-flex">
    <div class="uk-width-1-2">
        <f:form.textfield id="powermail_field_email" name="tx_powermail_pi1[field][email]" value="{email}"
                          placeholder="Your email ..." type="email"/>
    </div>
    <div class="uk-width-1-2">
        <f:form.button type="submit" class="uk-button uk-button-primary button-newsletter">
            Anmelden
        </f:form.button>
    </div>
    <f:form.hidden value="1" name="tx_powermail_pi1[type]"/>
    <f:form.hidden value="1" name="no_cache"/>
</f:form>

1 Answers1

0

First of all, you don't have to use Fluid ViewHelpers for creating your footer form. Simply use a HTML-Form with POST and some fields. The action of the form should contain the URL of the powermail form. If the fields are using correct names, powermail will prefill the input fields.

More information how to prefill fields in powermail is documented here: https://github.com/einpraegsam/powermail/blob/develop/Documentation/ForAdministrators/BestPractice/PrefillField.md

Alex Kellner
  • 1,263
  • 6
  • 11
  • Thank you for your comment! After tinkering with the code a little, I noticed that I had to remove the name attribute on the submit button in order for the prefill to work. Now the footer form functions how it should. Even if that's the solution you gave me, I still want you to thank you for the nudge in the right direction. – MascaraSnake Jun 23 '22 at 13:57