Skip to content

setOptions on TwigField will remove the template #267

@mamazu

Description

@mamazu

The problem

The TwigField is basically just a normal field with a default template. The problem is if you want to change the options of this field it will either have to specify the template again or you will lose it.

Example

<?php

$field = TwigField::create('some_field', '@Sylius/some_template.html.twig')
    ->setOptions(['vars' => ['labels' => 'path/to/label'])
;

Will result in the options being:

[
    'vars' => ['labels' => 'path/to/label']
]

and not:

[
    'template' => '@Sylius/some_template.html.twig',
    'vars' => ['labels' => 'path/to/label']
]

Possible solution

The quick and easy answer would be to have the TwigField extend the Field and change the behavior of the setOptions function to merge with the template. This would be a big change though.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions