[FrameworkBundle] Fix title and placeholder rendering in php form templates.
This commit is contained in:
parent
9a70bbbdb2
commit
f82193db99
@ -6,5 +6,5 @@ name="<?php echo $view->escape($full_name) ?>"
|
||||
<?php if ($max_length): ?>maxlength="<?php echo $view->escape($max_length) ?>" <?php endif ?>
|
||||
<?php if ($pattern): ?>pattern="<?php echo $view->escape($pattern) ?>" <?php endif ?>
|
||||
<?php foreach ($attr as $k => $v): ?>
|
||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape(in_array($v, array('placeholder', 'title')) ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
||||
<?php printf('%s="%s" ', $view->escape($k), $view->escape(in_array($k, array('placeholder', 'title')) ? $view['translator']->trans($v, array(), $translation_domain) : $v)) ?>
|
||||
<?php endforeach; ?>
|
||||
|
@ -1898,4 +1898,18 @@ abstract class AbstractLayoutTest extends \Symfony\Component\Form\Test\FormInteg
|
||||
|
||||
$this->assertSame('<form method="get" action="http://example.com/directory" class="foobar">', $html);
|
||||
}
|
||||
|
||||
public function testTranslatedAttributes()
|
||||
{
|
||||
$view = $this->factory->createNamedBuilder('name', 'form')
|
||||
->add('firstName', 'text', array('attr' => array('title' => 'Foo')))
|
||||
->add('lastName', 'text', array('attr' => array('placeholder' => 'Bar')))
|
||||
->getForm()
|
||||
->createView();
|
||||
|
||||
$html = $this->renderForm($view);
|
||||
|
||||
$this->assertMatchesXpath($html, '/form//input[@title="[trans]Foo[/trans]"]');
|
||||
$this->assertMatchesXpath($html, '/form//input[@placeholder="[trans]Bar[/trans]"]');
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user