@@ -70,12 +70,12 @@ public static function make(string $name, ?Field $field = null): Input
7070 if (isset ($ field ->config ['dependsOnField ' ]) && $ field ->config ['dependsOnField ' ]) {
7171 $ input = self ::addFieldDependency ($ input , $ field );
7272 }
73-
73+
7474 // Add dynamic options first (from relationships, etc.)
7575 $ input = self ::addOptionsToInput ($ input , $ field );
76-
76+
7777 // Set static options as fallback if no dynamic options were added
78- if (empty ($ field ->config ['optionType ' ]) || !is_array ($ field ->config ['optionType ' ]) || !in_array ('relationship ' , $ field ->config ['optionType ' ])) {
78+ if (empty ($ field ->config ['optionType ' ]) || ! is_array ($ field ->config ['optionType ' ]) || ! in_array ('relationship ' , $ field ->config ['optionType ' ])) {
7979 $ input = $ input ->options ($ field ->config ['options ' ] ?? self ::getDefaultConfig ()['options ' ]);
8080 }
8181
@@ -110,13 +110,12 @@ protected static function addFieldDependency(Input $input, Field $field): Input
110110 // The field name in the form is {valueColumn}.{field_ulid}
111111 $ dependentFieldName = "values. {$ dependsOnField }" ;
112112 $ dependentValue = $ get ($ dependentFieldName );
113-
113+
114114 // Show this field only when the dependent field has a value
115- return !empty ($ dependentValue );
115+ return ! empty ($ dependentValue );
116116 });
117117 }
118118
119-
120119 public static function mutateFormDataCallback (Model $ record , Field $ field , array $ data ): array
121120 {
122121 if (! property_exists ($ record , 'valueColumn ' )) {
@@ -258,30 +257,30 @@ public function getForm(): array
258257 ->options (function ($ record , $ component ) {
259258 // Try to get the form slug from various sources
260259 $ formSlug = null ;
261-
260+
262261 // Method 1: From the record's model_key (most reliable)
263262 if ($ record && isset ($ record ->model_key )) {
264263 $ formSlug = $ record ->model_key ;
265264 }
266-
265+
267266 // Method 2: From route parameters as fallback
268- if (!$ formSlug ) {
267+ if (! $ formSlug ) {
269268 $ routeParams = request ()->route ()?->parameters() ?? [];
270269 $ formSlug = $ routeParams ['record ' ] ?? $ routeParams ['form ' ] ?? $ routeParams ['id ' ] ?? null ;
271270 }
272-
271+
273272 // Method 3: Try to get from the component's owner record if available
274- if (!$ formSlug && method_exists ($ component , 'getOwnerRecord ' )) {
273+ if (! $ formSlug && method_exists ($ component , 'getOwnerRecord ' )) {
275274 $ ownerRecord = $ component ->getOwnerRecord ();
276275 if ($ ownerRecord ) {
277276 $ formSlug = $ ownerRecord ->getKey ();
278277 }
279278 }
280-
281- if (!$ formSlug ) {
279+
280+ if (! $ formSlug ) {
282281 return ['debug ' => 'No form slug found. Record: ' . ($ record ? json_encode ($ record ->toArray ()) : 'null ' )];
283282 }
284-
283+
285284 // Get all select fields in the same form
286285 $ fields = \Backstage \Fields \Models \Field::where ('model_type ' , 'App\Models\Form ' )
287286 ->where ('model_key ' , $ formSlug )
@@ -292,17 +291,17 @@ public function getForm(): array
292291 ->orderBy ('name ' )
293292 ->pluck ('name ' , 'ulid ' )
294293 ->toArray ();
295-
294+
296295 if (empty ($ fields )) {
297296 return ['debug ' => 'No select fields found for form: ' . $ formSlug . '. Total fields: ' . \Backstage \Fields \Models \Field::where ('model_type ' , 'App\Models\Form ' )->where ('model_key ' , $ formSlug )->count ()];
298297 }
299-
298+
300299 return $ fields ;
301300 })
302301 ->searchable ()
303302 ->live (),
304303 ]),
305- ]),
304+ ]),
306305 Tab::make ('Rules ' )
307306 ->label (__ ('Rules ' ))
308307 ->schema ([
0 commit comments