FilamentF
Filament9mo ago
aldec

Get form state of 'parent' form inside a relationship

I have a helper function setting a label or visibility of form fields based spatie settings. Which setting is applicable is dependent on a property/form component. Inside my rather complex form I have multiple relationships. The helper functions try access the property of the 'parent' form via $get('myProperty'), but it is not accessible anymore. Can I traverse these form states?

function fieldVisibility(string $fieldKey): Closure
    {
        return function (callable $get) use ($fieldKey) {
            $settings = app(RoadworksSettings::class);
            $applicationType = $get('type');
            $applicationTypeKey = Str::slug($applicationType, '_');
            return $settings->fieldConfigurations[$applicationTypeKey][$fieldKey]['visible'] ?? true;
        };
    }
Solution
$get('../type') or ../../type etc
Was this page helpful?