filamentphp / filament

A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS.
https://filamentphp.com
MIT License
19.14k stars 2.95k forks source link

When the tab title is in Chinese, the Form Tab is not separated correctly. #14080

Open cityisempty opened 2 months ago

cityisempty commented 2 months ago

Package

filament/filament

Package Version

V3.2.0

Laravel Version

v11

Livewire Version

No response

PHP Version

PHP 8.3

Problem description

When I have two tabs in the form, if both tabs have Chinese titles, then their contents are merged into one, and both tabs are in a selected state.

截屏2024-08-28 22 12 25 截屏2024-08-28 22 12 58

Expected behavior

When using tabs, Chinese characters should be handled correctly.

Steps to reproduce

Tabs\Tab::make(__('基本信息'))->schema([
TextInput::make('title')
                            ->label(__('Post Title'))
                            ->required()
                            ->maxLength(255)
                            ->live(onBlur: true)]),
Tabs\Tab::make(__('(E)扩展信息'))->schema([
                        Placeholder::make(__('扩展信息')),

                        Hidden::make('user_id')
                            ->default(auth()->user()->id)
                            ->required(),

                        Hidden::make('post_type')
                            ->default('post')
                            ->required()])

When I use the above code, the error occurs. If I change it to the following code, the result is correct.

Tabs\Tab::make(__('Title '))->schema([
TextInput::make('title')
                            ->label(__('Post Title'))
                            ->required()
                            ->maxLength(255)
                            ->live(onBlur: true)]),
Tabs\Tab::make(__('Other Info '))->schema([
                        Placeholder::make(__('扩展信息')),

                        Hidden::make('user_id')
                            ->default(auth()->user()->id)
                            ->required(),

                        Hidden::make('post_type')
                            ->default('post')
                            ->required()])

Reproduction repository (issue will be closed if this is not valid)

https://github.com/cityisempty/filament-issue

Relevant log output

No response

Donate 💰 to fund this issue

Fund with Polar

zxc88645 commented 2 months ago

The issue comes from forms/src/Components/Tabs/Tab.php infolists/src/Components/Tabs/Tab.php


    final public function __construct(string $label)
    {
        $this->label($label);
        $this->id(Str::slug($label));
    }
Str::slug($title, $separator = '-', $language = 'en', $dictionary = ['@' => 'at'])

The language parameter defaults to en, and when encountering Chinese characters, it results in an empty string.

I recommend modifying it to:

$this->id(Str::slug(Str::transliterate($label, strict: true)));