|
|
@@ -94,14 +94,17 @@ class NewsResource extends Resource
|
|
94
|
94
|
TextInput::make('title')
|
|
95
|
95
|
->label("標題")
|
|
96
|
96
|
->reactive()
|
|
97
|
|
- ->afterStateHydrated(function ($state, callable $set) {
|
|
98
|
|
- $set('title_length', mb_strlen($state ?? ''));
|
|
99
|
|
- })
|
|
100
|
|
- ->afterStateUpdated(function ($state, callable $set) {
|
|
101
|
|
- $set('title_length', mb_strlen($state ?? ''));
|
|
102
|
|
- })
|
|
103
|
97
|
->helperText(function (callable $get) {
|
|
104
|
|
- $length = $get('title_length') ?? 0;
|
|
|
98
|
+
|
|
|
99
|
+ $activeLocale = $get('activeLocale') ?? 'zh_TW';
|
|
|
100
|
+
|
|
|
101
|
+ $value = $get('title');
|
|
|
102
|
+
|
|
|
103
|
+ $text = is_array($value)
|
|
|
104
|
+ ? (string) ($value[$activeLocale] ?? '')
|
|
|
105
|
+ : (string) ($value ?? '');
|
|
|
106
|
+
|
|
|
107
|
+ $length = mb_strlen($text);
|
|
105
|
108
|
$max = 24;
|
|
106
|
109
|
|
|
107
|
110
|
$divClass = 'text-limit-amount';
|
|
|
@@ -123,14 +126,17 @@ class NewsResource extends Resource
|
|
123
|
126
|
->label("短文")
|
|
124
|
127
|
|
|
125
|
128
|
->reactive()
|
|
126
|
|
- ->afterStateHydrated(function ($state, callable $set) {
|
|
127
|
|
- $set('description_length', mb_strlen($state ?? ''));
|
|
128
|
|
- })
|
|
129
|
|
- ->afterStateUpdated(function ($state, callable $set) {
|
|
130
|
|
- $set('description_length', mb_strlen($state ?? ''));
|
|
131
|
|
- })
|
|
132
|
129
|
->helperText(function (callable $get) {
|
|
133
|
|
- $length = $get('description_length') ?? 0;
|
|
|
130
|
+
|
|
|
131
|
+ $activeLocale = $get('activeLocale') ?? 'zh_TW';
|
|
|
132
|
+
|
|
|
133
|
+ $value = $get('description');
|
|
|
134
|
+
|
|
|
135
|
+ $text = is_array($value)
|
|
|
136
|
+ ? (string) ($value[$activeLocale] ?? '')
|
|
|
137
|
+ : (string) ($value ?? '');
|
|
|
138
|
+
|
|
|
139
|
+ $length = mb_strlen($text);
|
|
134
|
140
|
$max = 84;
|
|
135
|
141
|
|
|
136
|
142
|
$divClass = 'text-limit-amount';
|