FillPdfFormFieldForm.php in FillPDF 5.0.x
File
src/Form/FillPdfFormFieldForm.php
View source
<?php
namespace Drupal\fillpdf\Form;
use Drupal\Component\Datetime\TimeInterface;
use Drupal\Core\Entity\ContentEntityForm;
use Drupal\Core\Entity\EntityRepositoryInterface;
use Drupal\Core\Entity\EntityTypeBundleInfoInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\fillpdf\FillPdfAdminFormHelperInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class FillPdfFormFieldForm extends ContentEntityForm {
protected $adminFormHelper;
public function __construct(EntityRepositoryInterface $entity_repository, FillPdfAdminFormHelperInterface $admin_form_helper, EntityTypeBundleInfoInterface $entity_type_bundle_info, TimeInterface $time) {
parent::__construct($entity_repository, $entity_type_bundle_info, $time);
$this->adminFormHelper = $admin_form_helper;
}
public static function create(ContainerInterface $container) {
return new static($container
->get('entity.repository'), $container
->get('fillpdf.admin_form_helper'), $container
->get('entity_type.bundle.info'), $container
->get('datetime.time'));
}
public function form(array $form, FormStateInterface $form_state) {
$form = parent::form($form, $form_state);
$form['prefix']['widget']['0']['value']['#rows'] = 3;
$form['value']['token_help'] = $this->adminFormHelper
->getAdminTokenForm();
$form['suffix']['widget']['0']['value']['#rows'] = 3;
$form['extra'] = [
'#type' => 'details',
'#title' => $this
->t('Transform values'),
];
$form['replacements']['#group'] = 'extra';
return $form;
}
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$form_state
->setRedirect('entity.fillpdf_form.edit_form', [
'fillpdf_form' => $this->entity->fillpdf_form->target_id,
]);
return parent::save($form, $form_state);
}
}