mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Fix errors in custom field rendering and administration
This commit is contained in:
parent
c704ffa379
commit
170bb9586d
5
.changes/unreleased/Fixed-20231124-121854.yaml
Normal file
5
.changes/unreleased/Fixed-20231124-121854.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: Fixed
|
||||||
|
body: Fix rendering of custom fields
|
||||||
|
time: 2023-11-24T12:18:54.023062767+01:00
|
||||||
|
custom:
|
||||||
|
Issue: "222"
|
5
.changes/unreleased/Fixed-20231124-122955.yaml
Normal file
5
.changes/unreleased/Fixed-20231124-122955.yaml
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
kind: Fixed
|
||||||
|
body: Fix various errors in custom fields administration
|
||||||
|
time: 2023-11-24T12:29:55.417513892+01:00
|
||||||
|
custom:
|
||||||
|
Issue: ""
|
@ -30,7 +30,7 @@ class CustomFieldController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* Creates a new CustomField entity.
|
* Creates a new CustomField entity.
|
||||||
*
|
*
|
||||||
* @Route("/{_locale}/admin/customfield/new", name="customfield_new")
|
* @Route("/{_locale}/admin/customfield/new", name="customfield_create")
|
||||||
*/
|
*/
|
||||||
public function createAction(Request $request)
|
public function createAction(Request $request)
|
||||||
{
|
{
|
||||||
|
@ -232,7 +232,7 @@ class CustomFieldsGroupController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* Finds and displays a CustomFieldsGroup entity.
|
* Finds and displays a CustomFieldsGroup entity.
|
||||||
*
|
*
|
||||||
* @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup/show")
|
* @Route("/{_locale}/admin/customfieldsgroup/{id}/show", name="customfieldsgroup_show")
|
||||||
*/
|
*/
|
||||||
public function showAction(mixed $id)
|
public function showAction(mixed $id)
|
||||||
{
|
{
|
||||||
@ -256,7 +256,7 @@ class CustomFieldsGroupController extends AbstractController
|
|||||||
/**
|
/**
|
||||||
* Edits an existing CustomFieldsGroup entity.
|
* Edits an existing CustomFieldsGroup entity.
|
||||||
*
|
*
|
||||||
* @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup/update")
|
* @Route("/{_locale}/admin/customfieldsgroup/{id}/update", name="customfieldsgroup_update")
|
||||||
*/
|
*/
|
||||||
public function updateAction(Request $request, mixed $id)
|
public function updateAction(Request $request, mixed $id)
|
||||||
{
|
{
|
||||||
@ -383,7 +383,7 @@ class CustomFieldsGroupController extends AbstractController
|
|||||||
$em = $this->getDoctrine()->getManager();
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
|
||||||
$customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
|
$customFieldsGroupIds = $em->createQuery('SELECT g.id FROM '
|
||||||
.'ChillCustomFieldsBundle:CustomFieldsDefaultGroup d '
|
.CustomFieldsDefaultGroup::class.' d '
|
||||||
.'JOIN d.customFieldsGroup g')
|
.'JOIN d.customFieldsGroup g')
|
||||||
->getResult(Query::HYDRATE_SCALAR);
|
->getResult(Query::HYDRATE_SCALAR);
|
||||||
|
|
||||||
|
@ -280,7 +280,7 @@ class CustomFieldChoice extends AbstractCustomField
|
|||||||
$template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig';
|
$template = '@ChillCustomFields/CustomFieldsRendering/choice.html.twig';
|
||||||
|
|
||||||
if ('csv' === $documentType) {
|
if ('csv' === $documentType) {
|
||||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice.csv.twig';
|
$template = 'ChillCustomFieldsBundle/CustomFieldsRendering/choice.csv.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->templating
|
return $this->templating
|
||||||
|
@ -68,7 +68,7 @@ class CustomFieldDate extends AbstractCustomField
|
|||||||
{
|
{
|
||||||
$validatorFunction = static function ($value, ExecutionContextInterface $context) {
|
$validatorFunction = static function ($value, ExecutionContextInterface $context) {
|
||||||
try {
|
try {
|
||||||
$date = new \DateTime($value);
|
$date = new \DateTime((string) $value);
|
||||||
} catch (\Exception) {
|
} catch (\Exception) {
|
||||||
$context->buildViolation('The expression "%expression%" is invalid', [
|
$context->buildViolation('The expression "%expression%" is invalid', [
|
||||||
'%expression%' => $value,
|
'%expression%' => $value,
|
||||||
@ -125,7 +125,7 @@ class CustomFieldDate extends AbstractCustomField
|
|||||||
return $date->format('Y-m-d');
|
return $date->format('Y-m-d');
|
||||||
|
|
||||||
default:
|
default:
|
||||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:date.'
|
$template = '@ChillCustomFields/CustomFieldsRendering/date.'
|
||||||
.$documentType.'.twig';
|
.$documentType.'.twig';
|
||||||
|
|
||||||
return $this->templating
|
return $this->templating
|
||||||
|
@ -96,7 +96,7 @@ class CustomFieldLongChoice extends AbstractCustomField
|
|||||||
public function render($value, CustomField $customField, $documentType = 'html')
|
public function render($value, CustomField $customField, $documentType = 'html')
|
||||||
{
|
{
|
||||||
$option = $this->deserialize($value, $customField);
|
$option = $this->deserialize($value, $customField);
|
||||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:choice_long.'
|
$template = '@ChillCustomFields/CustomFieldsRendering/choice_long.'
|
||||||
.$documentType.'.twig';
|
.$documentType.'.twig';
|
||||||
|
|
||||||
return $this->templating
|
return $this->templating
|
||||||
|
@ -95,7 +95,7 @@ class CustomFieldNumber extends AbstractCustomField
|
|||||||
|
|
||||||
public function render($value, CustomField $customField, $documentType = 'html')
|
public function render($value, CustomField $customField, $documentType = 'html')
|
||||||
{
|
{
|
||||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:number.'
|
$template = '@ChillCustomFields/CustomFieldsRendering/number.'
|
||||||
.$documentType.'.twig';
|
.$documentType.'.twig';
|
||||||
$options = $customField->getOptions();
|
$options = $customField->getOptions();
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ class CustomFieldText extends AbstractCustomField
|
|||||||
$template = '@ChillCustomFields/CustomFieldsRendering/text.html.twig';
|
$template = '@ChillCustomFields/CustomFieldsRendering/text.html.twig';
|
||||||
|
|
||||||
if ('csv' === $documentType) {
|
if ('csv' === $documentType) {
|
||||||
$template = 'ChillCustomFieldsBundle:CustomFieldsRendering:text.csv.twig';
|
$template = '@ChillCustomFields/CustomFieldsRendering/text.csv.twig';
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->templating
|
return $this->templating
|
||||||
|
@ -11,6 +11,7 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace Chill\CustomFieldsBundle\Form;
|
namespace Chill\CustomFieldsBundle\Form;
|
||||||
|
|
||||||
|
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
|
||||||
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
use Chill\CustomFieldsBundle\Form\DataTransformer\CustomFieldsGroupToIdTransformer;
|
||||||
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
use Chill\CustomFieldsBundle\Service\CustomFieldProvider;
|
||||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||||
@ -45,7 +46,7 @@ class CustomFieldType extends AbstractType
|
|||||||
|
|
||||||
if ('entity' === $options['group_widget']) {
|
if ('entity' === $options['group_widget']) {
|
||||||
$builder->add('customFieldsGroup', EntityType::class, [
|
$builder->add('customFieldsGroup', EntityType::class, [
|
||||||
'class' => 'ChillCustomFieldsBundle:CustomFieldsGroup',
|
'class' => CustomFieldsGroup::class,
|
||||||
'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()),
|
'choice_label' => fn ($g) => $this->translatableStringHelper->localize($g->getName()),
|
||||||
]);
|
]);
|
||||||
} elseif ('hidden' === $options['group_widget']) {
|
} elseif ('hidden' === $options['group_widget']) {
|
||||||
|
@ -1,4 +1,8 @@
|
|||||||
services:
|
services:
|
||||||
|
_defaults:
|
||||||
|
autowire: true
|
||||||
|
autoconfigure: true
|
||||||
|
|
||||||
Chill\CustomFieldsBundle\Controller\:
|
Chill\CustomFieldsBundle\Controller\:
|
||||||
resource: '../../Controller'
|
resource: '../../Controller'
|
||||||
tags: ['controller.service_arguments']
|
tags: ['controller.service_arguments']
|
||||||
|
Loading…
x
Reference in New Issue
Block a user