-
-
Notifications
You must be signed in to change notification settings - Fork 40
Upgrade guide
This guide shows all the steps for upgrading from v1 to v2.
-
Replace
site/plugins/sendform/
by theuniform/
directory of this repo. -
Rename the
.sendform__potty
honeypot CSS class to.uniform__potty
in your CSS and in all of your forms. Change thename
andid
of the honeypot field from_potty
towebsite
(why?, and dont forgetfor
of the label. If this produces a naming conflict, see how you can change the default honeypot name. -
Remove all
sendform
language variables from yoursite/languages/
files and replace them by the contents of the new language files of this repo. You can use theinclude_once
method, too (see the "Linking" section of this blog post to see how). -
If you used email snippets, replace them by their new counterparts. Note the new naming convention
uniform-<action>-<snippet>.php
, so you have to change the names in thesnippet
option of the form. If you created custom snippets, rename the$data
variable to$form
. -
Move the
$form = sendform(...)
call from the page template to the page controller (if you haven't done this already).
Now we have to change the old sendform()
call to the new uniform()
call. Let's walk through the changes with the extended example:
old call:
$form = sendform(
'registration-form',
'[email protected]',
array(
'subject' => 'Exhibition - New registration',
'required' => array(
'name' => ''
),
'validate' => array(
'attendees' => 'num'
),
'snippet' => 'sendform-table',
'copy' => array(
'[email protected]'
)
)
);
new call:
$form = uniform(
'registration-form',
array(
'required' => array(
'name' => '',
'_from' => 'email'
),
'validate' => array(
'attendees' => 'num'
),
'actions' => array(
array(
'_action' => 'email',
'to' => '[email protected]',
'sender' => '[email protected]',
'subject' => 'Exhibition - New registration',
'snippet' => 'uniform-email-table'
),
array(
'_action' => 'email',
'to' => '[email protected]',
'sender' => '[email protected]',
'subject' => 'Exhibition - New registration',
'snippet' => 'uniform-email-table'
)
)
)
);
There is one less argument in the function call, the receiver's email address. The Uniform plugin can now handle arbitrary form actions, so it is no longer restricted to sending emails. Because of this, subject
, snippet
and all the other options for sending an email are moved to the email action array in the actions
option. The required
and validate
options remain the same in function and position but note, that the _from
field now has to be explicitly declared as required.
The email action has two new arguments: to
and sender
. The first one contains the receiver's email address (previously the second argument of sendform()
) and the second one will be used as the sender of the email (more on this).
If you are still not sure how to refactor your very own sendform()
call, don't hesitate to open an issue and ask.