zikula-modules / Formicula

A template-driven form mailer for Zikula

Home Page:https://ziku.la

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Please change formicula so that it's forms post data objects/arrays

hvorragend opened this issue · comments

Currently formicula forms post individual fields. If this were to be changed to post an array of fields, extending formicula forms for custom uses, would be much easier. This would be an easy change to make and would make formicula much easier to extend.

Currently formicula_user_send() does the following:

$uduname? = FormUtil::getPassedValue('uname', (isset($argsuname?)) ? $argsuname? : , 'GETPOST');

    $uduemail? = FormUtil::getPassedValue('uemail', (isset($argsuemail?)) ? $argsuemail? : , 'GETPOST');
    $udurl? = FormUtil::getPassedValue('url', (isset($argsurl?)) ? $argsurl? : , 'GETPOST');
    $udphone? = FormUtil::getPassedValue('phone', (isset($argsphone?)) ? $argsphone? : , 'GETPOST');
    $udcompany? = FormUtil::getPassedValue('company', (isset($argscompany?)) ? $argscompany? : , 'GETPOST');
    $udlocation? = FormUtil::getPassedValue('location', (isset($argslocation?)) ? $argslocation? : , 'GETPOST');
    $udcomment? = FormUtil::getPassedValue('comment', (isset($argscomment?)) ? $argscomment? : , 'GETPOST');

Would it not be much easier to do

$ud = FormUtil::getPassedValue ('userdata', array(), 'GETPOST');

and then do

$uduname? = isset($argsuname?) ? $argsuname? : $uduname?;

This would allow you to extend the posted values without having to worry about them being captured from POST. Any extensions with new fields could then be handled only by templates.

I've just seen that square brackets are not correctly displayed by in the examples above. I think/hope it's still clear what I mean though.
Change History
comment:1 Changed 3 years ago by Landseer

This would break existing form templates. To be backwards compatible both ways need to be supported.
comment:2 Changed 3 years ago by Landseer

Milestone set to not yet defined

comment:3 Changed 3 months ago by espaan

Milestone changed from not yet defined to 3.0.0
Status set to pending-review

I'm trying to get this on the road with a BW compatilibilty flag.

I think this would still be a wise way to go. And of course with backwards compatibility with a flag in the form. Not specifying the flag e.g. dataformat would indicate plain, specifying dataformat array would indicate the array code int he form handling should be used.