Accessing Form State

I am having difficulty to understand how to access form data in Form Builder.

Let say I have this form and I want to generate part code and part description automatically based on other form fields.

What I'm thinking right now is adding afterStateUpdate to every fields and trigger a method to generate the part code. But, inside afterStateUpdate I only have access to it's own field state not the entire state.

If I try to use $this->form->getState() it doesn't work, (is it because it's a static function?).

                    ->afterStateUpdated(function (Set $set, $state) {
                        $set('part_code', OrderResource::generatePartCode($state));
                    }),
Screenshot_2023-11-02_at_12.52.15.png
Was this page helpful?