Custom builder help

Hi, I’ve been trying to make a new custom builder plugin based on GitHub - enguerr/MauticBeefreeBundle: FreeBee.io plugin editor for mautic, since that one is not working with the current versions of mautic, but am having a lot of problems with it.

My current issue is the error “Could not load type “builder_section”: class does not exist.”

I believe the problem is in the following section:

...
$sectionForm = $this->get('form.factory')->create('builder_section');
...
return $this->delegateView(
            [
                'viewParameters' => [
                    'form'               => $this->setFormTheme($form, 'MauticEmailBundle:Email:form.html.php', 'MauticEmailBundle:FormTheme\Email'),
                    'isVariant'          => $entity->isVariant(true),
                    'slots'              => $this->buildSlotForms($slotTypes),
                    'sections'           => $this->buildSlotForms($sections),
                    'themes'             => $this->factory->getInstalledThemes('email', true),
                    'bfthemes'           => $bfrepo->getInstalledThemes('email', true),
                    'version'            => $lastversion,
                    'version_post'       => $postversion,
                    'email'              => $entity,
                    'forceTypeSelection' => $forceTypeSelection,
                    'attachmentSize'     => $attachmentSize,
                    'builderAssets'      => trim(preg_replace('/\s+/', ' ', $this->getAssetsForBuilder())), // strip new lines
                    'sectionForm'        => $sectionForm->createView(),
                    'permissions'        => $permissions,
                    'previewUrl'         => $this->generateUrl(
                        'mautic_email_preview',
                        ['objectId' => $entity->getId()],
                        true
                    ),
                ],
                'contentTemplate' => 'MauticBeefreeBundle:Email:form.html.php',
                'passthroughVars' => [
                    'activeLink'      => '#mautic_email_index',
                    'mauticContent'   => 'email',
                    'updateSelect'    => InputHelper::clean($this->request->query->get('updateSelect')),
                    'route'           => $this->generateUrl('mautic_email_action', $routeParams),
                    'validationError' => $this->getFormErrorForBuilder($form),
                ],
            ]
        );

Can someone assist me with this? I’m using Mautic 4.1.1, if that helps with anything

I wonder if the underlaying template has to be compatible with the new builder.
In the config files of templates we always have to list the builder it’s compatible with.

Maybe, the problem is when clicking the “new” button in the email page

Each email you create in Mautic needs to have a compatible template - I can see you have none.
Copy one of the html templates (maybe the blank one) and add to the config:
yourbuildername has to be added otherwise the template cannot show

{
  "name": "Great Theme",
  "author": "Mr. Robot",
  "authorUrl": "https://mautic.org",
  "builder": ["yourbuildername"],
  "features": [
    "email"
  ]
}

Read more:

Just did as instructed, cleaned the cache, and still the same error, nothing changed there.

The error log shows this:

[2022-03-09 15:47:56] mautic.CRITICAL: Uncaught PHP Exception Symfony\Component\Form\Exception\InvalidArgumentException: "Could not load type "builder_section": class does not exist." at C:\xampp\htdocs\mautic\vendor\symfony\form\FormRegistry.php line 83 {"exception":"[object] (Symfony\\Component\\Form\\Exception\\InvalidArgumentException(code: 0): Could not load type \"builder_section\": class does not exist. at C:\\xampp\\htdocs\\mautic\\vendor\\symfony\\form\\FormRegistry.php:83)
[stacktrace]
#0 C:\\xampp\\htdocs\\mautic\\vendor\\symfony\\form\\FormFactory.php(60): Symfony\\Component\\Form\\FormRegistry->getType('builder_section')
#1 C:\\xampp\\htdocs\\mautic\\vendor\\symfony\\form\\FormFactory.php(32): Symfony\\Component\\Form\\FormFactory->createBuilder('builder_section', NULL, Array)
#2 C:\\xampp\\htdocs\\mautic\\plugins\\MauticBeefreeBundle\\Controller\\MauticBeefreeEmailController.php(378): Symfony\\Component\\Form\\FormFactory->create('builder_section')

To fix this, I used
$sectionForm = $this->get('form.factory')->create(BuilderSectionType::class);

Now my only issue is getting it to save the template

Hi NichMaia, do you plan to share your plugin? I’ve been using engerr’s plugin and I really love it.