Extend Blade Components

Let's say you want to extend the FieldRoot

1. Create a Blade component

php artisan make:component FieldRoot

2. Extend and replace any method

If you want to change the FieldRoot styling, then it's enough to extend the original blade component and replace the class() method.

<?php

namespace App\View\Components;

use Tanthammar\TallForms\Components\FieldRoot as OriginalFieldRoot;
use Tanthammar\TallForms\Traits\Helpers;

class FieldRoot extends OriginalFieldRoot
{
    public function class(): void
    {
        // return your own styling classes
    }
}

3. Replace the component in tall-forms config.

//components
 'field-root' => \App\View\Components\FieldRoot::class,
composer dump-autoload
php artisan config:clear
php artisan cache:clear
php artisan view:clear

Thats all -> done :)

Last updated