예제 #1
0
 /**
  * @param string $presetName name of the preset to use
  * @return string the rendered form head
  */
 public function render($presetName = 'default')
 {
     $content = '';
     $presetConfiguration = $this->formBuilderFactory->getPresetConfiguration($presetName);
     $stylesheets = isset($presetConfiguration['stylesheets']) ? $presetConfiguration['stylesheets'] : array();
     foreach ($stylesheets as $stylesheet) {
         $content .= sprintf('<link href="%s" rel="stylesheet">', $this->resolveResourcePath($stylesheet['source']));
     }
     $javaScripts = isset($presetConfiguration['javaScripts']) ? $presetConfiguration['javaScripts'] : array();
     foreach ($javaScripts as $javaScript) {
         $content .= sprintf('<script src="%s"></script>', $this->resolveResourcePath($javaScript['source']));
     }
     return $content;
 }
 /**
  * @param string $presetName
  * @return string
  */
 public function render($presetName = 'default')
 {
     $mergedConfiguration = array();
     $presetConfiguration = $this->formBuilderFactory->getPresetConfiguration($presetName);
     $supertypeResolver = new \TYPO3\Form\Utility\SupertypeResolver($presetConfiguration['formElementTypes']);
     $mergedConfiguration['formElementTypes'] = $supertypeResolver->getCompleteMergedTypeDefinition(TRUE);
     $mergedConfiguration['formElementGroups'] = isset($presetConfiguration['formElementGroups']) ? $presetConfiguration['formElementGroups'] : array();
     $stylesheets = isset($presetConfiguration['stylesheets']) ? $presetConfiguration['stylesheets'] : array();
     $mergedConfiguration['stylesheets'] = array();
     foreach ($stylesheets as $stylesheet) {
         if (isset($stylesheet['skipInFormBuilder']) && $stylesheet['skipInFormBuilder'] === TRUE) {
             continue;
         }
         $mergedConfiguration['stylesheets'][] = $this->resolveResourcePath($stylesheet['source']);
     }
     $javaScripts = isset($presetConfiguration['javaScripts']) ? $presetConfiguration['javaScripts'] : array();
     $mergedConfiguration['javaScripts'] = array();
     foreach ($javaScripts as $javaScript) {
         if (isset($javaScript['skipInFormBuilder']) && $javaScript['skipInFormBuilder'] === TRUE) {
             continue;
         }
         $mergedConfiguration['javaScripts'][] = $this->resolveResourcePath($javaScript['source']);
     }
     $mergedConfiguration['endpoints']['formPageRenderer'] = $this->controllerContext->getUriBuilder()->uriFor('renderformpage');
     $mergedConfiguration['endpoints']['loadForm'] = $this->controllerContext->getUriBuilder()->uriFor('loadform');
     $mergedConfiguration['endpoints']['saveForm'] = $this->controllerContext->getUriBuilder()->uriFor('saveform');
     $mergedConfiguration['endpoints']['editForm'] = $this->controllerContext->getUriBuilder()->uriFor('index');
     $mergedConfiguration['endpoints']['previewForm'] = $this->controllerContext->getUriBuilder()->uriFor('show', array(), 'FormManager');
     $mergedConfiguration['csrfToken'] = $this->securityContext->getCsrfProtectionToken();
     $mergedConfiguration['formPersistenceIdentifier'] = $this->controllerContext->getArguments()->getArgument('formPersistenceIdentifier')->getValue();
     $mergedConfiguration['presetName'] = $presetName;
     $availablePresets = array();
     foreach ($this->formBuilderFactory->getPresetNames() as $presetName) {
         $presetConfiguration = $this->formBuilderFactory->getPresetConfiguration($presetName);
         $availablePresets[] = array('name' => $presetName, 'title' => isset($presetConfiguration['title']) ? $presetConfiguration['title'] : $presetName);
     }
     $mergedConfiguration['availablePresets'] = $availablePresets;
     return json_encode($mergedConfiguration);
 }
 public function build(array $configuration, $presetName)
 {
     $configuration = array('type' => 'TYPO3.Form:Form', 'identifier' => 'testing', 'label' => 'My Label', 'renderables' => array(array('type' => 'TYPO3.Form:Page', 'identifier' => 'general', 'renderables' => array(array('type' => 'TYPO3.Form:TestingFormElementWithSubElements', 'identifier' => 'subel')))));
     return parent::build($configuration, $presetName);
 }