Validate Custom Panel Dialog

Hi All,

Does anyone know how a custom dialog can be validated? I have a custom panel view (kind of similar to Advanced Panel area | Kirby CMS in terms of functionality except it uses a database and has additional functionality to the tutorial)

When i add a new database entry i create a similar dialog to the kirby add pages dialog, the code for it is as follows:

    return [
        'pattern' => 'brokerages/dialog/add',
        'load'    => function () {
            return [
                'component' => 'k-form-dialog',
                'props' => [
                    'fields' => [
                        'broker_name' => [
                            'label' => 'Brokerage Name',
                            'type'  => 'text',
                            'required' => true
                        ],
                        'broker_slug' => [
                            'label' => 'Brokerage Slug',
                            'type'  => 'slug',
                            'sync' => 'broker_name',
                        ],
                        'broker_email' => [
                            'label' => 'Brokerage Email',
                            'type'  => 'email',
                            'required' => true
                        ]
                    ],
                    'icon' => 'check',
                    'theme' => 'positive',
                    'submitButton' => 'Add Brokerage'
                ]
            ];
        },
        'submit' => function () {
            $brokerage = Brokerages::add([
                'broker_name' => get('broker_name'),
                'broker_slug' => get('broker_slug'),
                'broker_email' => get('broker_email')
            ]);
            return $brokerage;
        }
    ];

I have the required option on the field, i assumed kirby would handle this out the box, is this something I’d have to validate myself? If so how could this be achieved within the dialog?

Thanks

Yes, have a look at the recipe. In the Product class update method you can find validation examples: Advanced Panel area | Kirby CMS

Doh, somehow missed that! Thanks @texnixe