Skip to content

Conversation

@loic425
Copy link
Member

@loic425 loic425 commented Oct 28, 2025

With this feature, we'll be able to define custom field types.

As an example:

#[AsField]
final class DateTimeField implements FieldTypeInterface
{
    public function __construct(
        private readonly TwigFieldType $twigFieldType,
    ) {
    }

    public function render(Field $field, $data, array $options): string
    {
        return $this->twigFieldType->render($field, $data, $options);
    }

    public function configureOptions(OptionsResolver $resolver): void
    {
        $this->twigFieldType->configureOptions($resolver);

        $resolver->setDefaults([
            'template' => 'shared/grid/field/datetime.html.twig',
            'vars' => [
                'th_class' => 'w-1 text-center',
            ],
        ]);
    }
}

@loic425 loic425 force-pushed the feat/as-field branch 2 times, most recently from 663753a to a52741e Compare October 28, 2025 11:07
@loic425 loic425 added the Feature New feature proposals. label Nov 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Feature New feature proposals.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants