Create form for adding document info in metadata property of signature

This commit is contained in:
Julie Lenaerts 2024-07-10 12:48:48 +02:00
parent 8f358112b1
commit 52a9aab73f
3 changed files with 88 additions and 0 deletions

View File

@ -0,0 +1,62 @@
<?php
namespace Chill\MainBundle\Form;
use Chill\MainBundle\Entity\Workflow\EntityWorkflowStepSignature;
use Chill\MainBundle\Form\Type\ChillDateType;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\NumberType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\OptionsResolver\OptionsResolver;
class WorkflowSignatureMetadataType extends AbstractType
{
public function __construct(private ParameterBagInterface $parameterBag, private RequestStack $requestStack)
{
}
public function buildForm(FormBuilderInterface $builder, array $options)
{
$documentTypeChoices = $this->parameterBag->get('chill_main.document_type_choices');
$locale = $this->requestStack->getCurrentRequest()->getLocale();
$choices = [];
foreach ($documentTypeChoices as $documentType) {
foreach ($documentType['labels'] as $label) {
if ($label['lang'] === $locale) {
$choices[$label['label']] = $documentType['key'];
break;
}
}
}
$builder
->add('documentType', ChoiceType::class, [
'label' => 'workflow.signature_zone.metadata.docType',
'expanded' => false,
'required' => true,
'choices' => $choices,
])
->add('documentNumber', TextType::class, [
'required' => true,
'label' => 'workflow.signature_zone.metadata.docNumber',
])
->add('expirationDate', ChillDateType::class, [
'required' => true,
'input' => 'datetime_immutable',
'label' => 'workflow.signature_zone.metadata.docExpiration',
]);
}
/* public function configureOptions(OptionsResolver $resolver): void
{
$resolver->setDefaults([
'data_class' => EntityWorkflowStepSignature::class,
]);
}*/
}

View File

@ -0,0 +1,24 @@
{% extends '@ChillMain/layout.html.twig' %}
{% block title %}
{{ 'Signature'|trans }}
{% endblock %}
{% block content %}
<div class="col-10 workflow">
<h1 class="mb-5">{{ 'workflow.signature_zone.metadata.sign_by'|trans({ '%name%' : person.firstname ~ ' ' ~ person.lastname}) }}</h1>
{% if metadata_form is not null %}
{{ form_start(metadata_form) }}
{{ form_row(metadata_form.documentType) }}
{{ form_row(metadata_form.documentNumber) }}
{{ form_row(metadata_form.expirationDate) }}
<ul class="record_actions">
<li>
{{ form_widget(metadata_form.submit, { 'attr' : { 'class' : 'btn btn-submit' }} ) }}
</li>
</ul>
{{ form_end(metadata_form) }}
{% endif %}
</div>
{% endblock %}

View File

@ -133,6 +133,8 @@ services:
Chill\MainBundle\Form\WorkflowStepType: ~
Chill\MainBundle\Form\WorkflowSignatureMetadataType: ~
Chill\MainBundle\Form\DataMapper\PrivateCommentDataMapper:
autowire: true
autoconfigure: true