Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add options to blocks #1688

Open
joyceverheije opened this issue Jun 8, 2022 · 4 comments
Open

Add options to blocks #1688

joyceverheije opened this issue Jun 8, 2022 · 4 comments

Comments

@joyceverheije
Copy link
Collaborator

joyceverheije commented Jun 8, 2022

I would like to be able to pass some options through the blocks to avoid creating a new block for each variation I need.

For example, we create a lot of lite version of blocks with less fields, for different templates. Which means creating a new one and extracting or duplicating the initial form, to enrich it or simplify it.

Example block form:

@formField('medias', [
    'name' => 'image',
    'label' => 'Image',
])

@formField('radios', [
    'name' => 'ratio',
    'label' => "Ratio",
    'options' => collect(['Full' => 'Full', 'Half' => 'Half']),
    'default' => 'Full',
    'inline' => true
])

@formField('checkbox', [
    'name' => 'border',
    'label' => 'Show border'
])

@formField('checkbox', [
    'name' => 'background_color',
    'label' => 'Show background color'
])

Example block lite form:

@formField('medias', [
    'name' => 'image',
    'label' => 'Image',
])

@formField('radios', [
    'name' => 'ratio',
    'label' => "Ratio",
    'options' => collect(['Full' => 'Full', 'Half' => 'Half']),
    'default' => 'Full',
    'inline' => true
])

@formField('checkbox', [
    'name' => 'border',
    'label' => 'Show border'
])

Solution:

@formField('medias', [
    'name' => 'image',
    'label' => 'Image',
])

@formField('radios', [
    'name' => 'ratio',
    'label' => "Ratio",
    'options' => collect(['Full' => 'Full', 'Half' => 'Half']),
    'default' => 'Full',
    'inline' => true
])

@formField('checkbox', [
    'name' => 'border',
    'label' => 'Show border'
])

@if($withBackgroundColor)
    @formField('checkbox', [
	  'name' => 'background_color',
	  'label' => 'Show background color'
    ])
@endif

Module form:

@formField('block_editor', [
    'blocks' => [
        'text',
        'image' => [
	    'withBackgroundColor' => true,
	],
    ]
])

With the multiple block editor feature, I assume a use case would be to pass the same block with different options to different block editors within the same form, but I know this will be more complex to support because of the block templates inlined in the html once per block type.

@haringsrob
Copy link
Contributor

That's a great idea, I will check this for Twill 3.x

@alitak
Copy link

alitak commented Aug 10, 2022

Hello,

I would to add some other feature request for this idea.

It would be nice if I could pass some formField attributes to the block editor, like this:

@formField('block_editor', [
    'blocks' => [
        'quote' => [
            'quote' => ['translated' => true],
        ],
        'text',
        'image',
    ],
])

As a result of this the inputField named quote in the block editor quote would be translatable and we should not create a custom block editor only because of some custom attributes.

@devimako

This comment was marked as off-topic.

@haringsrob

This comment was marked as off-topic.

@ifox ifox moved this to Next in Twill roadmap Feb 9, 2024
@ifox ifox moved this from Next to Beyond in Twill roadmap Feb 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Beyond
Development

No branches or pull requests

5 participants