/** * @dataProvider viewVariablesProvider * * @param array $vars * @param string|array $classToAppend * @param array $expectedVars */ public function testAddClass($vars, $classToAppend, $expectedVars) { $formView = new FormView(); $formView->vars = $vars; FormUtils::appendClass($formView, $classToAppend); $this->assertSame($expectedVars, $formView->vars); }
/** * {@inheritdoc} */ public function buildView(FormView $view, FormInterface $form, array $options) { parent::buildView($view, $form, $options); FormUtils::appendClass($view, 'no-uniform'); $view->vars['translatable'] = $options['translatable']; $view->vars['allow_empty_color'] = $options['allow_empty_color']; $view->vars['empty_color'] = $options['empty_color']; }
/** * Builds form view in order to show on page, recreates form if update mode * due to validation errors should not be shown if submitted in 'update mode' * NOTE: it was impossible to use validation_groups because of structure of client validation framework * * @return FormView */ public function getFormView() { $isUpdateOnly = $this->request->get(IntegrationChannelHandler::UPDATE_MARKER, false); $form = $this->form; if ($isUpdateOnly) { $config = $form->getConfig(); $form = $config->getFormFactory()->createNamed($form->getName(), $config->getType()->getName(), $form->getData(), $this->options); } $view = $form->createView(); FormUtils::appendClass($view->children['connectors'], 'hide'); FormUtils::appendClass($view->children['type'], 'hide'); return $view; }
/** * {@inheritdoc} */ public function finishView(FormView $view, FormInterface $form, array $options) { if (isset($view->children['owner'], $view->children['owner']->vars['choices']) && count($view->children['owner']->vars['choices']) < 2) { FormUtils::appendClass($view->children['owner'], 'hide'); } }
/** * {@inheritdoc} */ public function finishView(FormView $view, FormInterface $form, array $options) { if (array_key_exists('label', $view->children)) { FormUtils::appendClass($view->children['label'], 'hide'); } }