How to display custom FormBuilder error

pepijn - 2 months ago

I made a FormBuilder with a custom Handler. In the handler I'm importing a bunch of entries based on third party URL's. For some URL's, this process fails and I want to be able to flash a custom error message.

The code below doesn't produce any flash messages. What am I doing wrong?

    public function handle(FormBuilder $builder) {
        $urls = (array) $this->getUrls($builder);
        $result = $this->dispatch(new ImportEntries($urls));

        // this doesn't seem to work
        $builder->addFormError('somefield', 'some message');

ryanthompson - 2 months ago

This is used in the front end via the form function? If so you don't need the flash there. That's probably wiping it before the FormController flashes it itself here:

pepijn - 2 months ago

@ryanthompson This is a FormBuilder for the admin (not used in frontend, no custom twig templates). When I remove the flash line, the flash messages are still not shown.

The handler is defined on the FormBuilder as follows:

protected $actions = [
        'import' => [
            'text' => 'Import',
            'type' => 'success',
            'handler' => ImportFormHandler::class,