Jump to content

Recommended Posts

Posted

Hello @perplexed

Are you sure that you have added this method to the WireMail object and not to the form object? I have tested it without problems.

Please take a look here at the example of a simple contact form and let me know if this solves your problem.

Jürgen

Posted

Thank you Jurgen. By comparing your template with my code I see what I did now.

I copied a template you created on 15.02.2023 but somehow I'd deleted the line

'<p>[[TITLE]]</p><ul>

from $body.

Dur!

Thanks again.

  • Like 1
  • 2 weeks later...
Posted

Hello @ all

The new version 2.3.0 comes with a brand new feature: the possibility to turn a form into a multi-step form.

Many thanks to @Jan S. for the idea and the support in testing during the development of the new feature.

In a nutshell:

A multi-step form is a long form divided into multiple steps. At the end of each step, the user clicks on a "Next" button to go to the next section. In the final step a summary of the data entered will be displayed to the user. The user now has the option to change some of the data if necessary before finally submitting the form.

Typical use cases are very long forms, surveys or quizzes.

multi-step-form.thumb.png.7f4274cf3af3ef97372447b390c04736.png

I have written an extra chapter in the docs with a lot more information, which you can find here.

There are only 2 restrictions for multi-step forms to work properly: 

  1. The send button must be after the last step (by the way, it wouldn't make sense to put it anywhere in between ;-))
  2. File upload fields must be placed in the last step (otherwise they won't work)

To turn a form into a multi-step form, you only need one new method: addStep()

You need to add this method to the form object in the places where you want to make the cut:

$form = new \FrontendForms\Form('simpleform');

$firstname = new \FrontendForms\InputText('firstname');
$firstname->setLabel('Firstname');
$firstname->setRule('required');
$form->add($firstname);

$lastname = new \FrontendForms\InputText('lastname');
$lastname->setLabel('Lastname');
$lastname->setRule('required');
$form->add($lastname);

$form->addStep(); // first step

$email = new \FrontendForms\InputEmail('email');
$email->setLabel('Input Email');
$email->setRule('required');
$form->add($email);

$form->addStep(); // second step

$birthday = new \FrontendForms\InputDate('date');
$birthday ->setLabel('Birthday');
$form->add($birthday );

$form->addStep(); // third step

$message = new \FrontendForms\Textarea('message');
$message->setLabel('My message');
$form->add($message);

$form->addStep(); // fourth step

$button = new \FrontendForms\Button('submit');
$button->setAttribute('value', 'Send');
$form->add($button);


if($form->isValid()){


    print_r($form->getValues());
    // do what you want

}

// render the form
$content .= $form->render();

echo $content;

That is all! You can find more examples here.

To be informed of all the changes in this release, please read the changelog.

As always, please keep an eye on whether everything is working as expected and report any issues you discover here or directly on GitHub.

Jürgen

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...