Skip to content

Instantly share code, notes, and snippets.

@bwaidelich
Last active July 10, 2017 15:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bwaidelich/60531d0e55d69bc93f5c7ba598d9e201 to your computer and use it in GitHub Desktop.
Save bwaidelich/60531d0e55d69bc93f5c7ba598d9e201 to your computer and use it in GitHub Desktop.
Fusion Based Form Elements (Spike)
<?php
namespace The\PackageName;
use Neos\Flow\Mvc\Controller\ControllerContext;
use Neos\Form\Core\Model\Renderable\RenderableInterface;
use Neos\Form\Core\Model\Renderable\RootRenderableInterface;
use Neos\Form\Core\Renderer\RendererInterface;
use Neos\Form\Core\Runtime\FormRuntime;
class FusionFormRenderer implements RendererInterface
{
/**
* @var ControllerContext
*/
private $controllerContext;
/**
* @var FormRuntime
*/
private $formRuntime;
public function setControllerContext(ControllerContext $controllerContext): void
{
$this->controllerContext = $controllerContext;
}
public function setFormRuntime(FormRuntime $formRuntime): void
{
$this->formRuntime = $formRuntime;
}
public function getFormRuntime(): FormRuntime
{
return $this->formRuntime;
}
public function renderRenderable(RootRenderableInterface $formRuntime): string
{
$formRuntime->beforeRendering($this->formRuntime);
if (!$formRuntime instanceof FormRuntime) {
// TODO exception
return '';
}
$fusionView = new FusionView();
$fusionView->setControllerContext($this->controllerContext);
// TODO configure $fusionView
return $fusionView->render();
}
}
Neos:
Form:
presets:
'fusion':
title: 'Fusion based Form Elements'
parentPreset: 'default'
formElementTypes:
'Neos.Form:Base':
renderingOptions:
templatePathPattern: ~
partialPathPattern: ~
layoutPathPattern: ~
'Neos.Form:Form':
rendererClassName: 'The\PackageName\FusionFormRenderer'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment