Skip to content

Commit 39d7585

Browse files
author
roadiz-ci
committed
Merge branch hotfix/v2.3.16
1 parent 1ef46fb commit 39d7585

File tree

2 files changed

+68
-1
lines changed

2 files changed

+68
-1
lines changed

src/Forms/CustomFormFieldType.php

Lines changed: 58 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@
55
namespace Themes\Rozier\Forms;
66

77
use RZ\Roadiz\CoreBundle\Entity\CustomFormField;
8+
use RZ\Roadiz\CoreBundle\Form\DataListTextType;
89
use RZ\Roadiz\CoreBundle\Form\MarkdownType;
10+
use RZ\Roadiz\CoreBundle\Repository\CustomFormFieldRepository;
911
use Symfony\Component\Form\AbstractType;
1012
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
1113
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
@@ -16,6 +18,20 @@
1618

1719
class CustomFormFieldType extends AbstractType
1820
{
21+
public function __construct(
22+
private readonly CustomFormFieldRepository $customFormFieldRepository
23+
) {
24+
}
25+
26+
/**
27+
* @param CustomFormField $field
28+
* @return string[]
29+
*/
30+
protected function getAllGroupsNames(CustomFormField $field): array
31+
{
32+
return $this->customFormFieldRepository->findDistinctGroupNamesInCustomForm($field->getCustomForm());
33+
}
34+
1935
public function buildForm(FormBuilderInterface $builder, array $options): void
2036
{
2137
$builder->add('label', TextType::class, [
@@ -57,10 +73,51 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
5773
],
5874
]
5975
)
60-
->add('groupName', TextType::class, [
76+
->add('groupName', DataListTextType::class, [
6177
'label' => 'groupName',
6278
'required' => false,
6379
'help' => 'use_the_same_group_names_over_fields_to_gather_them_in_tabs',
80+
'list' => $this->getAllGroupsNames($builder->getData()),
81+
'listName' => 'group-names',
82+
'attr' => [
83+
'autocomplete' => 'off',
84+
],
85+
])
86+
->add('autocomplete', ChoiceType::class, [
87+
'label' => 'customForm.autocomplete',
88+
'help' => 'customForm.autocomplete.help',
89+
'choices' => [
90+
'off',
91+
'name',
92+
'honorific-prefix',
93+
'honorific-suffix',
94+
'given-name',
95+
'additional-name',
96+
'family-name',
97+
'nickname',
98+
'email',
99+
'username',
100+
'organization-title',
101+
'organization',
102+
'street-address',
103+
'country',
104+
'country-name',
105+
'postal-code',
106+
'bday',
107+
'bday-day',
108+
'bday-month',
109+
'bday-year',
110+
'sex',
111+
'tel',
112+
'tel-national',
113+
'url',
114+
'photo',
115+
],
116+
'placeholder' => 'autocomplete.no_autocomplete',
117+
'choice_label' => function ($choice, $key, $value) {
118+
return 'autocomplete.' . $value;
119+
},
120+
'required' => false,
64121
]);
65122
}
66123

src/Resources/views/custom-form-fields/list.html.twig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
<th>{% trans %}label{% endtrans %}</th>
2626
<th class="mobile-hidden">{% trans %}type{% endtrans %}</th>
2727
<th class="mobile-hidden">{% trans %}group{% endtrans %}</th>
28+
<th class="mobile-hidden">{% trans %}required{% endtrans %}</th>
2829
<th class="table-actions-row table-actions-row-2">{% trans %}actions{% endtrans %}</th>
2930
</tr>
3031
</thead>
@@ -40,6 +41,15 @@
4041
</td>
4142
<td class="mobile-hidden">{{ field.typeName|trans }}</td>
4243
<td class="mobile-hidden">{{ field.groupName|trans }}</td>
44+
<td class="mobile-hidden">
45+
{% if field.required %}
46+
<div class="uk-button-status"
47+
title="{% trans %}required{% endtrans %}"
48+
data-uk-tooltip="{animation:true}">
49+
<i class="uk-icon-asterisk"></i>
50+
</div>
51+
{% endif %}
52+
</td>
4353
<td class="table-actions-row table-actions-row-2">
4454
{% apply spaceless %}
4555
<a class="uk-button uk-button-content uk-button-small custom-form-field-edit-button rz-no-ajax-link" href="{{ path('customFormFieldsEditPage', { customFormFieldId: field.getId }) }}" title="{% trans %}edit{% endtrans %}" data-uk-tooltip="{animation:true}" data-index="{{ loop.index0 }}"><i class="uk-icon-rz-pencil"></i></a>

0 commit comments

Comments
 (0)