icetalker/filament-table-repeater 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

icetalker/filament-table-repeater

最新稳定版本:v2.0.2

Composer 安装命令:

composer require icetalker/filament-table-repeater

包简介

This is a package for Filament form component. Extends form Repeater, but shows in Table Layout.

README 文档

README

Repeater Component in Table layout for Filament Package

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

This is a package for Filament form component. Extends from Repeater, but display in Table Layout.

image

image

Installation

You can install the package via composer:

composer require icetalker/filament-table-repeater

You can publish the views using

php artisan vendor:publish --tag="filament-table-repeater"

Usage

use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;

protected function form(Form $form): Form
{
    return $form->schema([
        ...
        TableRepeater::make('items')
                ->relationship('items')
                ->schema([
                    Forms\Components\TextInput::make('product'),
                    ...
                ])
                ->reorderable()
                ->cloneable()
                ->collapsible()
                ->minItems(3)
                ->maxItems(5),

    ]);
}

Since this component extends from Filament\Forms\Components\Repeater, you can use most of its methods, except for a few methods like inset(), grid(), columns().

Other methods

colStyles

To customize styles for each cell, you can pass an array of component name as key and css style as value to colStyles(). See example below:

use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;

protected function form(Form $form): Form
{
    return $form->schema([
        ...
        TableRepeater::make('items')
            ->relationship('items')
            ->schema([
                Forms\Components\TextInput::make('product'),
                Forms\Components\TextInput::make('quantity'),
                ...
            ])
            ->colStyles([
                'product' => 'color: #0000ff; width: 250px;',
            ]),


    ]);
}

Besides, you can also pass a callback function to colStyles(). This may unlock more customization possibilities. See example below:

use Icetalker\FilamentTableRepeater\Forms\Components\TableRepeater;

protected function form(Form $form): Form
{
    return $form
        ->schema([
            ...
            Forms\Components\Grid::make(1)->schema([

                TableRepeater::make('items')
                    ->relationship('items')
                    ->schema([
                        Forms\Components\TextInput::make('product'),
                        Forms\Components\TextInput::make('quantity'),
                        ...
                    ])
                    ->colStyles(function(){
                        return [
                            'product' => 'color: #0000ff; width: 250px;',
                        ]
                    }),

            ]),

        ]);
}

Alternative

Since Filament v4, Reapeater Component has it own table() method. You could use it to achieve the same function if you are using the latest version.

Changelog

Please see CHANGELOG for more information on what has changed recently.

Contributing

Please see CONTRIBUTING for details.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 156.21k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 134
  • 点击次数: 1
  • 依赖项目数: 1
  • 推荐数: 0

GitHub 信息

  • Stars: 133
  • Watchers: 2
  • Forks: 27
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-06-28