FillPdfFormExportForm.php in FillPDF 8.4
File
src/Form/FillPdfFormExportForm.php
View source
<?php
namespace Drupal\fillpdf\Form;
use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Form\FormStateInterface;
use Drupal\fillpdf\SerializerInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FillPdfFormExportForm extends EntityForm {
protected $serializer;
public function __construct(SerializerInterface $serializer) {
$this->serializer = $serializer;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('fillpdf.serializer'));
}
public function form(array $form, FormStateInterface $form_state) {
parent::form($form, $form_state);
$entity = $this
->getEntity();
$code = $this->serializer
->getFormExportCode($entity);
$form = [];
$form['export'] = [
'#type' => 'textarea',
'#title' => $this
->t('FillPDF form configuration and mappings'),
'#default_value' => $code,
'#rows' => 30,
'#description' => $this
->t('Copy this code and then on the site you want to import to, go to the Edit page for the FillPDF form for which you want to import these mappings, and paste it in there.'),
'#attributes' => [
'style' => 'width: 97%;',
],
];
return $form;
}
public function buildForm(array $form, FormStateInterface $form_state) {
$form = parent::buildForm($form, $form_state);
unset($form['actions']);
$form['#after_build'] = [];
return $form;
}
}