Пример #1
0
 /**
  * Renders the forms of a container.
  *
  * @param Container $container
  * @param string $layout
  * @param array $parameter
  * @return string
  */
 public function render(Container $container, $layout = Form::LAYOUT_HORIZONTAL, $parameter = array())
 {
     $content = '';
     $content .= $container->renderPre($this->getView());
     if ($container instanceof ViewPartialProviderInterface) {
         return $this->getView()->partial($container->getViewPartial(), array('element' => $container));
     }
     foreach ($container as $element) {
         $parameterPartial = $parameter;
         if ($element instanceof ExplicitParameterProviderInterface) {
             $parameterPartial = array_merge($element->getParams(), $parameterPartial);
         }
         if ($element instanceof ViewPartialProviderInterface) {
             $parameterPartial = array_merge(array('element' => $element, 'layout' => $layout), $parameterPartial);
             $content .= $this->getView()->partial($element->getViewPartial(), $parameterPartial);
         } elseif ($element instanceof ViewHelperProviderInterface) {
             $helper = $element->getViewHelper();
             if (is_string($helper)) {
                 $helper = $this->getView()->plugin($helper);
             }
             $content .= $helper($element);
         } elseif ($element instanceof SummaryForm) {
             $content .= $this->getView()->summaryForm($element);
         } elseif ($element instanceof Container) {
             $content .= $this->render($element, $layout, $parameter);
         } else {
             $content .= $this->getView()->form($element, $layout, $parameter);
         }
     }
     $content .= $container->renderPost($this->getView());
     return $content;
 }
Пример #2
0
 public function propertiesProvider()
 {
     $object = new \stdClass();
     $container = new Container();
     $labeldContainer = new Container();
     $labeldContainer->setLabel('testLabel');
     $topContainer = new Container();
     $topContainer->setForm('child', ['__instance__' => $object])->setLabel('top');
     return [['Headscripts', ['default' => ['/js/jquery.bootstrapwizard.min.js'], 'value' => ['test/scripts']]], ['Form', ['value' => 'test', 'setter_args' => [$object], 'setter_exception' => ['\\InvalidArgumentException', 'Tab container must be of the type']]], ['Form', ['value' => 'test', 'setter_args' => [$container], 'setter_exception' => ['\\InvalidArgumentException', 'Container instances must have a label']]], ['Form', ['value' => 'test', 'setter_args' => [$labeldContainer], 'getter_args' => ['test', true], 'expect' => $labeldContainer]], ['Form', ['value' => 'test', 'setter_args' => ['Test/Container'], 'getter_args' => ['test', false], 'expect' => ['type' => 'Test/Container', 'name' => 'test', 'entity' => '*']]], ['Form', ['value' => 'test', 'setter_args' => [['type' => 'Test/Container']], 'getter_args' => ['test', false], 'expect' => ['type' => 'Test/Container', 'name' => 'test', 'entity' => '*']]], ['Form', ['value' => 'test', 'setter_args' => [[]], 'getter_args' => ['test', false], 'expect' => ['type' => 'Core/Container', 'name' => 'test', 'entity' => '*']]], ['Form', ['value' => 'test', 'setter_args' => [['forms' => []]], 'getter_args' => ['test', false], 'expect' => ['type' => 'Core/Container', 'name' => 'test', 'options' => ['forms' => []], 'entity' => '*']]], ['Form', ['value' => 'test', 'setter_args' => [['__instance__' => $object]], 'getter_args' => ['test'], 'getter_exception' => '\\UnexpectedValueException']], ['Form', ['value' => 'test', 'setter_args' => [['__instance__' => $container]], 'getter_args' => ['test'], 'getter_exception' => '\\UnexpectedValueException']], ['Form', ['value' => 'test', 'setter_args' => [['__instance__' => $labeldContainer]], 'getter_args' => ['test'], 'expect' => $labeldContainer]], ['Form', ['value' => 'test', 'setter_args' => [['__instance__' => $topContainer]], 'getter_args' => ['test.child'], 'expect' => $object]]];
 }
Пример #3
0
 /**
  * Renders the forms of a container.
  *
  * @param Container $container
  * @param string $layout
  * @param array $parameter
  * @return string
  */
 public function render(Container $container, $layout = Form::LAYOUT_HORIZONTAL, $parameter = array())
 {
     $content = '';
     $content .= $container->renderPre($this->getView());
     if ($container instanceof ViewPartialProviderInterface) {
         return $this->getView()->partial($container->getViewPartial(), array('element' => $container));
     }
     foreach ($container as $element) {
         $content .= $this->renderElement($element, $layout, $parameter);
     }
     $content .= $container->renderPost($this->getView());
     return $content;
 }
Пример #4
0
 public function testGetActionFor()
 {
     $this->assertNull($this->target->getActionFor('non-existent'));
     $key = 'name';
     $this->target->setForm($key, []);
     $this->assertSame($this->target->getActionFor($key), sprintf('?form=%s', $key));
 }
Пример #5
0
    public function renderPost(Renderer $renderer)
    {
        $coreformsjs = $renderer->basepath('/Core/js/core.forms.js');
        $javaScript = <<<JS
        \$(document).ready(function() {

            console.log('attached yk.forms.done to ', \$('form'));

             \$('form').on('yk.forms.done', function(event, data) {
                //if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {}
                if (typeof data != 'undefined' && typeof data['data'] != 'undefined') {
                    if (typeof data['data']['jobvalid'] != 'undefined' && data['data']['jobvalid'] === true) {
                        \$('#job_incomplete').hide();
                        \$('#finalize_jobentry').show();
                    }
                    else {
                        \$('#job_incomplete').show();
                        \$('#finalize_jobentry').hide();
                    }
                }
                \$('#job_errormessages').empty();

                if (typeof data['data']['errorMessage'] != 'undefined') {
                    \$('#job_errormessages').append(data['data']['errorMessage']);
                }
                console.debug('job-form-inline', event, data);
             });

        });
JS;
        $renderer->headScript()->appendScript($javaScript);
        return parent::renderPost($renderer);
    }
Пример #6
0
 public function setEntity($entity, $key = '*')
 {
     if ('*' == $key) {
         $this->setParam('cv', $entity->getId());
     }
     return parent::setEntity($entity, $key);
 }
Пример #7
0
 /**
  * Configures the apply form container.
  *
  * Currently only disables elements.
  *
  * @param Container $container
  */
 protected function configureContainer(Container $container)
 {
     /* @var $application Application */
     $application = $container->getEntity();
     $job = $application->getJob();
     /*
      * @TODO: Implement disable elements logic in entities, etc.
      *
     
     
     $config = $job->getApplyFormElementsConfig();
     if ($config) {
         $container->disableElements($config);
         return;
     }
     
     $config = $job->getOrganization()->getApplyFormElementsConfig();
     if ($config) {
         $container->disableElements($config);
         return;
     }
     */
     /** @var $settings \Applications\Entity\Settings */
     $settings = $job->getUser()->getSettings('Applications');
     $formSettings = $settings->getApplyFormSettings();
     if ($formSettings && $formSettings->isActive()) {
         $container->disableElements($formSettings->getDisableElements());
         return;
     }
     $config = $this->getServiceLocator()->get('Config');
     $config = isset($config['form_elements_config']['Applications/Apply']['disable_elements']) ? $config['form_elements_config']['Applications/Apply']['disable_elements'] : null;
     if ($config) {
         $container->disableElements($config);
     }
 }
Пример #8
0
 public function testRenderPrePost()
 {
     $renderer = new PhpRenderer();
     $this->assertSame($this->target->renderPost($renderer), '');
     $this->assertSame($this->target->renderPre($renderer), '');
 }
Пример #9
0
 /**
  * Gets a specific formular.
  *
  * This formular will be created upon the first retrievement.
  * If created, the formular gets passed the formular parameters set in this container.
  *
  * @see Container::getForm
  *
  * @param string $key
  * @param bool   $asInstance if false, the specification array is returned.
  *
  * @return Container|null|\Zend\Form\FormInterface|array
  * @throws \UnexpectedValueException
  */
 public function getForm($key, $asInstance = true)
 {
     $form = parent::getForm($key, $asInstance);
     /*
      * We must check here, if a lazy loaded top level form is an
      * instance of Container.
      */
     if ($asInstance && false === strpos($key, '.') && (!$form instanceof Container || !$form->getLabel())) {
         throw new \UnexpectedValueException(sprintf('The registered form with key "%s" is not an instance of \\Core\\Form\\Container or does not have a label.', $key));
     }
     return $form;
 }