Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace VKF\Info\FormFactories;
- use TYPO3\FLOW3\Annotations as FLOW3;
- use TYPO3\Form\Core\Model\FormDefinition;
- class ArticleFactory extends \TYPO3\Form\Factory\AbstractFormFactory {
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\ArticleGroupRepository
- */
- protected $articleGroupRepository;
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\BranchRepository
- */
- protected $branchRepository;
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\ContactRepository
- */
- protected $contactRepository;
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\CustomerRepository
- */
- protected $customerRepository;
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\DepartmentRepository
- */
- protected $departmentRepository;
- /**
- * @FLOW3\Inject
- * @var \VKF\Info\Domain\Repository\MaterialRepository
- */
- protected $materialRepository;
- /**
- * @param array $configuration
- * @param type $presetName
- * @return \TYPO3\Form\Core\Model\FormDefinition
- */
- public function build(array $configuration = null, $presetName = 'default') {
- $formConfiguration = $this->getPresetConfiguration($presetName);
- $form = new FormDefinition('articleForm', $formConfiguration);
- $basePage = $form->createPage('basePage');
- $name = $basePage->createElement('name', 'TYPO3.Form:SingleLineText');
- $name->setLabel('name:');
- $name->setProperty('placeholder', 'name of article...');
- $name->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $name->addValidator(new \TYPO3\FLOW3\Validation\Validator\StringLengthValidator(array(
- 'minimum' => 3,
- 'maximum' => 50
- )));
- $description = $basePage->createElement('description', 'TYPO3.Form:MultiLineText');
- $description->setLabel('description:');
- $description->setProperty('placeholder', 'description of article...');
- $description->addValidator(new \TYPO3\FLOW3\Validation\Validator\TextValidator());
- $articleGroup = $basePage->createElement('articleGroup', 'TYPO3.Form:SingleSelectDropdown');
- $articleGroup->setLabel('article group:');
- $articleGroup->setProperty('options', $this->articleGroupRepository->findAll());
- $articleGroup->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $articleGroup->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/SingleSelectDropdown.html');
- $branch = $basePage->createElement('branch', 'TYPO3.Form:SingleSelectDropdown');
- $branch->setLabel('branch:');
- $branch->setProperty('options', $this->branchRepository->findAll());
- $branch->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $branch->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/SingleSelectDropdown.html');
- $contact = $basePage->createElement('contact', 'TYPO3.Form:SingleSelectDropdown');
- $contact->setLabel('contact:');
- $contact->setProperty('options', $this->contactRepository->findAll());
- $contact->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $contact->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/SingleSelectDropdown.html');
- $customer = $basePage->createElement('customer', 'TYPO3.Form:SingleSelectDropdown');
- $customer->setLabel('customer:');
- $customer->setProperty('options', $this->customerRepository->findAll());
- $customer->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $customer->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/SingleSelectDropdown.html');
- $department = $basePage->createElement('department', 'TYPO3.Form:SingleSelectDropdown');
- $department->setLabel('department');
- $department->setProperty('options', $this->departmentRepository->findAll());
- $department->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $department->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/SingleSelectDropdown.html');
- $materialPage = $form->createPage('materialPage');
- $materials = $materialPage->createElement('materials', 'TYPO3.Form:MultipleSelectCheckboxes');
- $materials->setLabel('materials:');
- $materials->setProperty('options', $this->materialRepository->findAll());
- $materials->addValidator(new \TYPO3\FLOW3\Validation\Validator\NotEmptyValidator());
- $materials->setRenderingOption('templatePathPattern', 'resource://VKF.Info/Private/Form/Article/MultipleSelectCheckboxes.html');
- return $form;
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement