Skip to content

Instantly share code, notes, and snippets.

@bwaidelich
Last active July 11, 2022 07:54
Show Gist options
  • Save bwaidelich/c2d5afc2759c17cae030104f8bb8fcde to your computer and use it in GitHub Desktop.
Save bwaidelich/c2d5afc2759c17cae030104f8bb8fcde to your computer and use it in GitHub Desktop.
<?php
declare(strict_types=1);
namespace Wwwision\Test;
use Neos\Flow\Validation\Validator\NotEmptyValidator;
use Neos\Form\Core\Model\FormDefinition;
use Neos\Form\Factory\AbstractFormFactory;
final class FormFactory extends AbstractFormFactory
{
public function build(array $factorySpecificConfiguration, $presetName) {
$formConfiguration = $this->getPresetConfiguration($presetName);
$form = new FormDefinition('testform', $formConfiguration);
$page1 = $form->createPage('page1');
$password = $page1->createElement('password', 'Neos.Form:Password');
$password->addValidator(new NotEmptyValidator());
$password->setLabel('Password');
$confirmation = $page1->createElement('confirmation', 'Wwwision.Test:PasswordConfirmation');
$confirmation->setLabel('Confirm');
return $form;
}
}
<?php
declare(strict_types=1);
namespace Wwwision\Test\Form\Elements;
use Neos\Form\Core\Model\AbstractFormElement;
use Neos\Form\Core\Runtime\FormRuntime;
final class PasswordConfirmation extends AbstractFormElement
{
public function onSubmit(FormRuntime $formRuntime, &$elementValue)
{
\Neos\Flow\var_dump($formRuntime->getFormState()->getFormValues(), 'form values');
}
}
Neos:
Form:
presets:
default:
formElementTypes:
'Wwwision.Test:PasswordConfirmation':
superTypes:
'Neos.Form:FormElement': true
implementationClassName: Wwwision\Test\Form\Elements\PasswordConfirmation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment