Skip to content

[generate:plugin:block] Options can not be generated in no-interaction mode #3975

Open
@viveksr2

Description

Problem/Motivation

When generating block with fields like checkboxes, radio or combo, options need to be passed to the command. However, as the field info is separated by comma(,) thus the options get separated in-appropriately, thus broken code is generated.

Details to include:

  • The extraction of input parameters is done in ArrayInputTrait inside explodeInlineArray() method.

How to reproduce

Run following command and observe the form definition in the generated code.

drupal --no-interaction generate:plugin:block --module=TestModule --class=HeadingBlock --label=headingblock --plugin-id=headingblock --inputs='"name":"gender","type":"radio","label":"Gender","options":"array("male" => "Male", "female" => "Female")"'

Solution

Pipe separated options should be allowed. In block.html.twig template, options are rendered as it is, however they should be processed and an array should be generated.

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions