@@ -231,6 +231,13 @@ abstract class ModuleController extends Controller
231
231
*/
232
232
protected $ titleColumnKey = 'title ' ;
233
233
234
+ /**
235
+ * Label of the index column to use as name column.
236
+ *
237
+ * @var string
238
+ */
239
+ protected $ titleColumnLabel = 'Title ' ;
240
+
234
241
/**
235
242
* Name of the index column to use as identifier column.
236
243
*
@@ -245,6 +252,13 @@ abstract class ModuleController extends Controller
245
252
*/
246
253
protected $ titleFormKey ;
247
254
255
+ /**
256
+ * Label of the title field in forms.
257
+ *
258
+ * @var string
259
+ */
260
+ protected $ titleFormLabel = 'Title ' ;
261
+
248
262
/**
249
263
* Feature field name if the controller is using the feature route (defaults to "featured").
250
264
*
@@ -643,6 +657,30 @@ protected function setTitleColumnKey(string $titleColumnKey): void
643
657
$ this ->titleColumnKey = $ titleColumnKey ;
644
658
}
645
659
660
+ /**
661
+ * Sets the label to use for title column, defaults to `Title`.
662
+ */
663
+ protected function setTitleColumnLabel (string $ titleColumnLabel ): void
664
+ {
665
+ $ this ->titleColumnLabel = $ titleColumnLabel ;
666
+ }
667
+
668
+ /**
669
+ * Sets the field to use as title in forms, defaults to `title`.
670
+ */
671
+ protected function setTitleFormKey (string $ titleFormKey ): void
672
+ {
673
+ $ this ->titleFormKey = $ titleFormKey ;
674
+ }
675
+
676
+ /**
677
+ * Sets the label to use for title field in forms, defaults to `Title`.
678
+ */
679
+ protected function setTitleFormLabel (string $ titleFormLabel ): void
680
+ {
681
+ $ this ->titleFormLabel = $ titleFormLabel ;
682
+ }
683
+
646
684
/**
647
685
* Usually not required, but in case customization is needed you can use this method to set the name of the model
648
686
* this controller acts on.
@@ -789,6 +827,7 @@ protected function getIndexTableColumns(): TableColumns
789
827
$ columns ->add (
790
828
Text::make ()
791
829
->field ($ this ->titleColumnKey )
830
+ ->title ($ this ->titleColumnKey === 'title ' && $ this ->titleColumnLabel === 'Title ' ? twillTrans ('twill::lang.main.title ' ) : $ this ->titleColumnLabel )
792
831
->sortable ()
793
832
->linkToEdit ()
794
833
);
@@ -1731,6 +1770,7 @@ protected function getIndexData(array $prependScope = []): array
1731
1770
'permalink ' => $ this ->getIndexOption ('permalink ' ),
1732
1771
'bulkEdit ' => $ this ->getIndexOption ('bulkEdit ' ),
1733
1772
'titleFormKey ' => $ this ->titleFormKey ?? $ this ->titleColumnKey ,
1773
+ 'titleFormLabel ' => $ this ->titleFormLabel ?? $ this ->titleColumnLabel ,
1734
1774
'baseUrl ' => $ baseUrl ,
1735
1775
'permalinkPrefix ' => $ this ->getPermalinkPrefix ($ baseUrl ),
1736
1776
'additionalTableActions ' => $ this ->additionalTableActions (),
@@ -2211,6 +2251,7 @@ protected function form(?int $id, ?TwillModelContract $item = null): array
2211
2251
'moduleName ' => $ this ->moduleName ,
2212
2252
'routePrefix ' => $ this ->routePrefix ,
2213
2253
'titleFormKey ' => $ this ->titleFormKey ?? $ this ->titleColumnKey ,
2254
+ 'titleFormLabel ' => $ this ->titleFormLabel ?? $ this ->titleColumnLabel ,
2214
2255
'publish ' => $ item ->canPublish ?? true ,
2215
2256
'publishDate24Hr ' => Config::get ('twill.publish_date_24h ' ) ?? false ,
2216
2257
'publishDateFormat ' => Config::get ('twill.publish_date_format ' ) ?? null ,
0 commit comments