Skip to content
New issue

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

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

Already on GitHub? # to your account

Add title prefix support to component blocks. #2252

Merged
merged 1 commit into from
May 15, 2023
Merged

Conversation

haringsrob
Copy link
Contributor

This pr allows component blocks to set the title prefix and title field:

<?php

namespace App\View\Components\Twill\Blocks;

use A17\Twill\Services\Forms\Fields\BlockEditor;
use A17\Twill\Services\Forms\Fields\Wysiwyg;
use A17\Twill\Services\Forms\Form;
use A17\Twill\Services\Forms\Fields\Input;
use A17\Twill\View\Components\Blocks\TwillBlockComponent;
use Illuminate\Contracts\View\View;

class Demo extends TwillBlockComponent
{
    public static function getBlockTitleField(): ?string
    {
        return 'title';
    }

    public static function shouldHidePrefix(): bool {
        return true;
    }

    public function getForm(): Form
    {
        return Form::make([
            Input::make()->name('title'),
            Wysiwyg::make()->name('text'),
            BlockEditor::make()->name('left')
        ]);
    }

    public function render(): View
    {
        return view('components.twill.blocks.demo');
    }

}

@haringsrob
Copy link
Contributor Author

@ifox I removed the block argument from the getTitle because that was the intended purpose but that could never work.

@ifox ifox merged commit 55430f4 into 3.x May 15, 2023
@ifox ifox deleted the dynamic-block-title branch May 15, 2023 10:48
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants