Sterc / FormIt

A dynamic form processing Snippet for MODX Revolution
https://docs.modx.com/current/en/extras/formit
33 stars 58 forks source link

FormIt email hook overwrite last $_POST element #113

Closed nikolay-kozlov closed 4 years ago

nikolay-kozlov commented 7 years ago

I have a form

[[!FormIt?
&hooks=`email,myCustomHook`
&emailTpl=`sentEmailTpl`
&emailSubject=`Subject`
&emailTo=`email@example.com`
]]
<form method="post">
    <input type="text" name="name"/><br>
    <input type="text" name="phone"/><br>
    <input type="submit" name="submit" value="Send"/>
</form>

myCustomHook is just snippet:

echo '<pre>';
print_r($hook->getValues());
echo '</pre>';
exit;

When I send form with args «test name», «test phone», I got:

Array
(
    [name] => test name
    [phone] => test phone
    [submit] => test phone
)

Last element was overwritten. Must be:

Array
(
    [name] => test name
    [phone] => test phone
    [submit] => Send
)

formit-2.2.11-pl MODX Revolution 2.5.2-pl (traditional) PHP Version 7.0.8-0ubuntu0.16.04.3 Ubuntu 16.04.1 LTS

joeke commented 7 years ago

@nikolay-kozlov You're right, that shouldn't be happening. Gonna look into it soon.

nikolay-kozlov commented 7 years ago

File: core/components/formit/model/formit/fihooks.class.php Line: 448 Add unset($v); after foreach

devlanda commented 4 years ago

I could not reproduce this in the latest version. I will close this issue.