1、文件结构:
▾ modules/
▾ custom/
▾ my_custom_form_handler/
▾ src/
▾ Plugin/
▾ WebformHandler/
2、然后,您应该在WebformHandler目录中创建处理程序文件。我们将其称为ExampleFormHandler.php,文件应遵循以下模板:
<?php
namespace Drupal\my_custom_form_handler\Plugin\WebformHandler;
use Drupal\Core\Session\Account\Interface;
use Drupal\Core\Serialization\Yaml;
use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
use Guzzle\Http\Client;
use Guzzle\Http\Exception\RequestException;
/**
* Form submission handler.
*
* @WebformHandler(
* id = "example_form_handler",
* label = @Translation("Example form handler"),
* category = @Translation("Examples"),
* description = @Translation("An example form handler"),
* cardinality = Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_SINGLE,
* results = Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
* )
*/
class ExampleFormHandler extends WebformHandlerBase {
/**
* {@inheritdoc}
*/
public function submitForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
// Your code here.
}
}
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。