Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laravel Form Components Laravel Package

rawilk/laravel-form-components

A set of reusable Blade form components for Laravel that make building consistent forms quick and clean. Includes inputs, selects, checkboxes, radios, buttons, errors, and styling-friendly markup, with flexible config and easy customization.

View on GitHub
Deep Wiki
Context7

title: Overriding Classes sort: 4

Overriding Classes

When you override a component class with your own, you will need to update the class referenced for the component alias in the config. For the select component, it would look like this:

Custom Class:

<?php

namespace App\View;

use Rawilk\FormComponents\Components\Inputs\Select;

class MySelect extends Select
{
    // Override stuff here...

    /**
     * You will need to override this method to
     * let the BladeComponent parent class
     * know where to look for this component's
     * view.
     *
     * Alternatively, you can override the
     * "render" method.
     */
    public static function getName(): string
    {
        // 'inputs.select' is the directory structure in the package's view
        // files. If you're using your own view, you should override the `render`
        // method instead.
        return 'inputs.select';
    }
}

Config:

<?php

return [
    'components' => [
        // ...
        'select' => \App\View\MySelect::class,
    ],

    // ...
];

{note} If you choose to override a class, you will need to override either the getName method (as shown in code above) or override the render method, so the parent BladeComponent class will use the correct view.

Some component classes will also need to be bound in the container in a service provider since internally this package does not reference components by alias. One of those components is the label component, which is referenced by the form-group component internally. To have the correct class be used, you can bind the overridden class in a service provider in the register method:

<?php

namespace App\Providers;

use App\View\MyCustomLabelClass;
use Illuminate\Support\ServiceProvider;
use Rawilk\FormComponents\Components\Label;

class AppServiceProvider extends ServiceProvider
{
    public function register(): void
    {
        $this->app->bind(Label::class, MyCustomLabelClass::class);
    }
}

Any component classes you override should follow the same pattern as illustrated above in a service provider.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
besmartand-pro/php-quality-config
sentix/ai-chatbot
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity