@@ -29,58 +29,58 @@ protected static function getHasInnerFieldComponent()
2929 };
3030
3131 return Forms \Components \Repeater::make ('fields ' )
32- ->columnSpanFull ()
33- ->collapsible ()
34- ->itemLabel (fn (array $ state ): ?string => $ state ['name ' ] ?? null )
35- ->addActionLabel ('Add Field ' )
36- ->schema (static ::getHasInnerFieldFieldsSchema ())
37- ->defaultItems (1 )
38- ->extraItemActions ([
39- Forms \Components \Actions \Action::make ('editConfig ' )
40- ->icon ('heroicon-s-cog-8-tooth ' )
41- ->slideOver ()
42- // todo: add translation
43- ->modalHeading (fn (array $ arguments , Forms \Components \Repeater $ component ) => str_replace ([':field ' ], [$ getFieldForRepeaterAction ($ arguments , $ component ) ?? 'Field ' ], 'Edit :field configuration ' ))
44- ->modalIcon (fn (array $ arguments , Forms \Components \Repeater $ component ) => $ getFieldIconForRepeaterAction ($ arguments , $ component ))
45- ->disabled (fn (array $ arguments , Forms \Components \Repeater $ component ) => empty ($ getFieldForRepeaterAction ($ arguments , $ component )))
46- ->form (function (Forms \Form $ form , array $ arguments , Forms \Components \Repeater $ component ) use ($ getFieldForRepeaterAction ) {
47-
48- $ innerFieldTypeName = $ getFieldForRepeaterAction ($ arguments , $ component );
49-
50- if (filled ($ innerFieldTypeName ) &&
51- ($ fieldTypeConfig = FieldTypeHelper::getFieldTypeConfig ($ innerFieldTypeName ))
52- ) {
53- if ($ fieldTypeConfig ->isFieldTypeTranslatable ()) {
54- // display "translatable" field for the field type
55- return $ fieldTypeConfig ->getEnhancedFormSchema ();
56- } else {
57- return $ fieldTypeConfig ->getFormSchema ();
58- }
32+ ->columnSpanFull ()
33+ ->collapsible ()
34+ ->itemLabel (fn (array $ state ): ?string => $ state ['name ' ] ?? null )
35+ ->addActionLabel ('Add Field ' )
36+ ->schema (static ::getHasInnerFieldFieldsSchema ())
37+ ->defaultItems (1 )
38+ ->extraItemActions ([
39+ Forms \Components \Actions \Action::make ('editConfig ' )
40+ ->icon ('heroicon-s-cog-8-tooth ' )
41+ ->slideOver ()
42+ // todo: add translation
43+ ->modalHeading (fn (array $ arguments , Forms \Components \Repeater $ component ) => str_replace ([':field ' ], [$ getFieldForRepeaterAction ($ arguments , $ component ) ?? 'Field ' ], 'Edit :field configuration ' ))
44+ ->modalIcon (fn (array $ arguments , Forms \Components \Repeater $ component ) => $ getFieldIconForRepeaterAction ($ arguments , $ component ))
45+ ->disabled (fn (array $ arguments , Forms \Components \Repeater $ component ) => empty ($ getFieldForRepeaterAction ($ arguments , $ component )))
46+ ->form (function (Forms \Form $ form , array $ arguments , Forms \Components \Repeater $ component ) use ($ getFieldForRepeaterAction ) {
47+
48+ $ innerFieldTypeName = $ getFieldForRepeaterAction ($ arguments , $ component );
49+
50+ if (filled ($ innerFieldTypeName ) &&
51+ ($ fieldTypeConfig = FieldTypeHelper::getFieldTypeConfig ($ innerFieldTypeName ))
52+ ) {
53+ if ($ fieldTypeConfig ->isFieldTypeTranslatable ()) {
54+ // display "translatable" field for the field type
55+ return $ fieldTypeConfig ->getEnhancedFormSchema ();
56+ } else {
57+ return $ fieldTypeConfig ->getFormSchema ();
5958 }
59+ }
6060
61- return [];
62- })
63- ->fillForm (function (array $ arguments , Forms \Components \Repeater $ component ) use ($ getItemStateForRepeaterAction ) {
64- $ existingFieldConfig = $ getItemStateForRepeaterAction ($ arguments , $ component )['fieldConfig ' ];
65- if (! empty ($ existingFieldConfig )) {
66- return $ existingFieldConfig ;
67- }
68- })
69- ->action (function (array $ data , array $ arguments , Forms \Components \Repeater $ component ) use ($ getItemKeyForRepeaterAction ) {
61+ return [];
62+ })
63+ ->fillForm (function (array $ arguments , Forms \Components \Repeater $ component ) use ($ getItemStateForRepeaterAction ) {
64+ $ existingFieldConfig = $ getItemStateForRepeaterAction ($ arguments , $ component )['fieldConfig ' ];
65+ if (! empty ($ existingFieldConfig )) {
66+ return $ existingFieldConfig ;
67+ }
68+ })
69+ ->action (function (array $ data , array $ arguments , Forms \Components \Repeater $ component ) use ($ getItemKeyForRepeaterAction ) {
7070
71- $ itemKey = $ getItemKeyForRepeaterAction ($ arguments );
71+ $ itemKey = $ getItemKeyForRepeaterAction ($ arguments );
7272
73- $ itemState = $ component ->getRawItemState ($ itemKey );
73+ $ itemState = $ component ->getRawItemState ($ itemKey );
7474
75- $ itemState ['fieldConfig ' ] = $ data ;
75+ $ itemState ['fieldConfig ' ] = $ data ;
7676
77- $ component ->getChildComponentContainer ($ itemKey )->fill ($ itemState );
77+ $ component ->getChildComponentContainer ($ itemKey )->fill ($ itemState );
7878
79- $ component ->collapsed (false , shouldMakeComponentCollapsible: false );
79+ $ component ->collapsed (false , shouldMakeComponentCollapsible: false );
8080
81- $ component ->callAfterStateUpdated ();
82- }),
83- ]);
81+ $ component ->callAfterStateUpdated ();
82+ }),
83+ ]);
8484 }
8585
8686 protected static function getHasInnerFieldFieldsSchema (): array
@@ -108,7 +108,7 @@ protected static function getHasInnerFieldFieldsSchema(): array
108108 ->required ()
109109 ->helperText ('Label for the field ' )
110110 ->live ()->afterStateUpdated (fn ($ state , $ set ) => $ state ? $ set ('name ' , Str::slug ($ state )) : null ),
111-
111+
112112 Forms \Components \TextInput::make ('name ' )
113113 ->required ()
114114 ->helperText ('Unique name for the field ' ),
0 commit comments