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

Custom blocks: Block title is being displayed twice #2485

Open
Tofandel opened this issue Feb 22, 2024 · 4 comments
Open

Custom blocks: Block title is being displayed twice #2485

Tofandel opened this issue Feb 22, 2024 · 4 comments

Comments

@Tofandel
Copy link
Contributor

The block title is being displayed both in the repeater header and in the block content

image

image

This is wasting precious screen space

The default blocks don't seem to have this, but when you create you own blocks they all have this, is there any way to remove it?

@ifox
Copy link
Member

ifox commented Feb 22, 2024

If you have more than one field in a block, you do want a label on each field for clarity and accessibility purposes. In the case of blocks with a single field, I would agree with you and I believe you can do that by using an empty label (TBC in Twill 3 with the form builder, but I know for sure it was possible in Twill 2). However, the label on the block wrapper itself is something you can actually configure to use the content of one of the fields in the block itself, and you can decide to keep the prefix or not in that case. I know that's not exactly what you are talking about but I want to make sure you are aware of the full behavior. The default blocks are also not a great reference, see the discussion in #2410.

@Tofandel
Copy link
Contributor Author

Tofandel commented Feb 22, 2024

I realised that yes it's the label of the field and not the block which could be different

But it's not possible to set an empty label to a field, maybe we should allow it?

public function getForm(): Form
    {
        return Form::make([
            Wysiwyg::make()->name('text')->label('')->translatable()
        ]);
    }

image

All the fields have mandatoryProperties: ['label'] it seems

@Tofandel
Copy link
Contributor Author

Tofandel commented Feb 22, 2024

If I change

+ if ($this->{$property} === null) {
- if (! $this->{$property}) {
  throw new \InvalidArgumentException(
      "Missing required field property '$property' on " . $this::class
  );
}

Then it displays without a label and doesn't complain about it, but I don't know if the better solution would be to remove label from the mandatoryFields

@ifox
Copy link
Member

ifox commented Feb 22, 2024

Right, that's what I was suspecting would be blocking it on Twill 3. I think we could totally remove it from mandatoryFields to allow this use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants