renderRow example


abstract class AbstractBootstrap4LayoutTestCase extends AbstractBootstrap3LayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('name', TextType::class);
        $form->addError(new FormError('[trans]Error![/trans]'));
        $view = $form->createView();
        $html = $this->renderRow($view);

        $this->assertMatchesXpath($html,
            '/div [ ./label[@for="name"] [ ./span[@class="alert alert-danger d-block"] [./span[@class="d-block"] [./span[.="[trans]Error[/trans]"]] [./span[.="[trans]Error![/trans]"]] ] [count(./span)=1] ] /following-sibling::input[@id="name"] ] '
use Symfony\Component\Form\FormError;
use Symfony\Component\Security\Csrf\CsrfToken;

abstract class AbstractTableLayoutTestCase extends AbstractLayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
        $form->addError(new FormError('[trans]Error![/trans]'));
        $view = $form->createView();
        $html = $this->renderRow($view);

        $this->assertMatchesXpath($html,
            '/tr [ ./td [./label[@for="name"]] /following-sibling::td [ ./ul [./li[.="[trans]Error![/trans]"]] [count(./li)=1] /following-sibling::input[@id="name"] ] ] '

abstract class AbstractBootstrap4HorizontalLayoutTestCase extends AbstractBootstrap4LayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
        $form->addError(new FormError('[trans]Error![/trans]'));
        $view = $form->createView();
        $html = $this->renderRow($view);

        $this->assertMatchesXpath($html,
            '/div [ ./label[@for="name"] [ ./span[@class="alert alert-danger d-block"] [./span[@class="d-block"] [./span[.="[trans]Error[/trans]"]] [./span[.="[trans]Error![/trans]"]] ] [count(./span)=1] ] /following-sibling::div[./input[@id="name"]] ] '
use Symfony\Component\Form\FormError;
use Symfony\Component\Security\Csrf\CsrfToken;

abstract class AbstractDivLayoutTestCase extends AbstractLayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType');
        $form->addError(new FormError('[trans]Error![/trans]'));
        $view = $form->createView();
        $html = $this->renderRow($view);

        $this->assertMatchesXpath($html,
            '/div [ ./label[@for="name"] /following-sibling::ul [./li[.="[trans]Error![/trans]"]] [count(./li)=1] /following-sibling::input[@id="name"] ] '
        );
$html = $this->renderHelp($view);

        $this->assertMatchesXpath($html, '/p', 0);
    }

    public function testHelpSetLinkFromWidget()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, [
            'help' => 'Help text test!',
        ]);
        $view = $form->createView();
        $html = $this->renderRow($view);

        // Test if renderHelp method is implemented (throw SkippedTestError if not)         $this->renderHelp($view);

        $this->assertMatchesXpath($html,
            '//input [@aria-describedby="name_help"] '
        );
    }

    

                    $isFirstRow = false;
                    $hasTitle = false;
                }

                if ($vertical) {
                    $isHeader = false;
                    $isFirstRow = false;
                }

                if ($horizontal) {
                    $this->renderRow($row$this->style->getCellRowFormat()$this->style->getCellHeaderFormat());
                } else {
                    $this->renderRow($row$isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
                }
            }
        }
        $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());

        $this->cleanup();
        $this->rendered = true;
    }

    

        );
    }

    public function testCheckboxRowWithHelp()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
        $html = $this->renderRow($form->createView()['label' => 'foo', 'help' => 'really helpful text']);

        $this->assertMatchesXpath($html,
            '/div [@class="form-group"] [ ./span[text() = "[trans]really helpful text[/trans]"] ] '
        );
    }

    

                    $isFirstRow = false;
                    $hasTitle = false;
                }

                if ($vertical) {
                    $isHeader = false;
                    $isFirstRow = false;
                }

                if ($horizontal) {
                    $this->renderRow($row$this->style->getCellRowFormat()$this->style->getCellHeaderFormat());
                } else {
                    $this->renderRow($row$isHeader ? $this->style->getCellHeaderFormat() : $this->style->getCellRowFormat());
                }
            }
        }
        $this->renderRowSeparator(self::SEPARATOR_BOTTOM, $this->footerTitle, $this->style->getFooterTitleFormat());

        $this->cleanup();
        $this->rendered = true;
    }

    
/** * Abstract class providing test cases for the Bootstrap 5 Twig form theme. * * @author Romain Monteil <monteil.romain@gmail.com> */
abstract class AbstractBootstrap5LayoutTestCase extends AbstractBootstrap4LayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('')->add('name', TextType::class);
        $form->get('name')->addError(new FormError('[trans]Error![/trans]'));
        $html = $this->renderRow($form->get('name')->createView());

        $this->assertMatchesXpath($html,
            '/div [@class="mb-3"] [ ./label[@for="name"] /following-sibling::input[@id="name"] /following-sibling::div [@class="invalid-feedback d-block"] [.="[trans]Error![/trans]"] ] [count(./div)=1] '
/** * Abstract class providing test cases for the Bootstrap 5 horizontal Twig form theme. * * @author Romain Monteil <monteil.romain@gmail.com> */
abstract class AbstractBootstrap5HorizontalLayoutTestCase extends AbstractBootstrap5LayoutTestCase
{
    public function testRow()
    {
        $form = $this->factory->createNamed('')->add('name', TextType::class);
        $form->get('name')->addError(new FormError('[trans]Error![/trans]'));
        $html = $this->renderRow($form->get('name')->createView());

        $this->assertMatchesXpath($html,
            '/div [@class="mb-3 row"] [ ./label [@for="name"] [@class="col-form-label col-sm-2 required"] /following-sibling::div [@class="col-sm-10"] [ ./input[@id="name"] /following-sibling::div [@class="invalid-feedback d-block"] [.="[trans]Error![/trans]"] ] [count(./div)=1] ] '
$html = $this->renderStart($form->createView()[
            'attr' => ['class' => 'foobar'],
        ]);

        $this->assertSame('<form name="form" method="get" action="http://example.com/directory" class="foobar form-horizontal">', $html);
    }

    public function testCheckboxRow()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
        $view = $form->createView();
        $html = $this->renderRow($view['label' => 'foo']);

        $this->assertMatchesXpath($html, '/div[@class="form-group"]/div[@class="col-sm-2" or @class="col-sm-10"]', 2);
    }

    public function testCheckboxRowWithHelp()
    {
        $form = $this->factory->createNamed('name', 'Symfony\Component\Form\Extension\Core\Type\CheckboxType');
        $html = $this->renderRow($form->createView()['label' => 'foo', 'help' => 'really helpful text']);

        $this->assertMatchesXpath($html,
            '/div [@class="form-group"] [ ./div[@class="col-sm-2" or @class="col-sm-10"] /following-sibling::div[@class="col-sm-2" or @class="col-sm-10"] [ ./span[text() = "[trans]really helpful text[/trans]"] ] ] '
Home | Imprint | This part of the site doesn't use cookies.