generateForm
The method $this->generateForm($routename)
generates a form from the form-definitions in the plugin yaml configuration.
- @param: (string) $routename. The name of the route.
- @return: (string|false) Returns the generated form if successful, otherwise returns false.
Example Usage
<?php
namespace Plugins\Myplugin;
use \Typemill\Plugin;
class Myplugin extends Plugin
{
...
public function myFunction()
{
# Data will be send as post-request to the route with the name 'contact.send'
$form = $this->generateForm('contact.send');
}
}
A public form definition in the plugin yaml file might look like this:
public:
fields:
name:
type: text
label: name_label
required: true
email:
type: email
label: email_label
required: true
subject:
type: text
label: subject_label
required: true
message:
type: textarea
label: message_label
required: true
See chapter about public forms for more details. Check the plugin contactform as a first starting point how to work with public forms.