Closed alexandre-melard closed 11 years ago
We don't have any legend in the bundle. So it looks like you are already doing some custom rendering.
J'ai remarqué que le seul formulaire où il n'y avait pas cette balise legend était celui du login, or lorsque je regarde les vues twig, tu écrit completement le formulaire alors que pour les autres il est obtenu à partir d'un {{ form_widget(form) }}
this looks like an issue cause by a custom them you are using
Sorry, I'm tired, I was writing in French...
the only difference I see is that you don't build the Form in the same way in the login window
<form action="{{ path("fos_user_security_check") }}" method="post">
<input type="hidden" name="_csrf_token" value="{{ csrf_token }}" />
<label for="username">{{ 'security.login.username'|trans({}, 'FOSUserBundle') }}</label>
<input type="text" id="username" name="_username" value="{{ last_username }}" required="required" />
<label for="password">{{ 'security.login.password'|trans({}, 'FOSUserBundle') }}</label>
<input type="password" id="password" name="_password" required="required" />
<input type="checkbox" id="remember_me" name="_remember_me" value="on" />
<label for="remember_me">{{ 'security.login.remember_me'|trans({}, 'FOSUserBundle') }}</label>
<input type="submit" id="_submit" name="_submit" value="{{ 'security.login.submit'|trans({}, 'FOSUserBundle') }}" />
</form>
and in the other formas:
<form action="{{ path('fos_user_profile_edit') }}" {{ form_enctype(form) }} method="POST" class="fos_user_profile_edit">
{{ form_widget(form) }}
<div>
<input type="submit" value="{{ 'profile.edit.submit'|trans({}, 'FOSUserBundle') }}" />
</div>
</form>
For example, so I was wondering if it wasn't the form builder that was messing up
I'm looking everywhere, I post as soon as I find it..
Ok, it's definitly added with the {{ form_widget(form) }} so I will give a look in the form factory..
@mylen Are you using a custom form theme or custom form extensions ? This form legend is not added by this bundle and does not appear when using it with the core Symfony theme
Ok, I think I found it..
I am using as you do a Form Type:
in this code, there is a getName function:
public function getName()
{
return 'project';
}
I tried to play with the name, it is this name that is output as legend when the {{ form_widget(form) }} is rendered by the form factory:
namespace Symfony\Component\Form;
use Symfony\Component\Form\Exception\UnexpectedTypeException;
class FormFactory implements FormFactoryInterface
{
//...
/**
* {@inheritdoc}
*/
public function createBuilder($type = 'form', $data = null, array $options = array(), FormBuilderInterface $parent = null)
{
$name = $type instanceof FormTypeInterface || $type instanceof ResolvedFormTypeInterface
? $type->getName()
: $type;
return $this->createNamedBuilder($name, $type, $data, $options, $parent);
}
//...
Now your telling me that the rendering might be corrupted by a plugin I installed... I will look further to that
Ok, I found it!!
I am using MopaBootstrapBundle that defines an extension for form with a legend tag! https://github.com/mylen/MopaBootstrapBundle/blob/master/Form/Extension/LegendFormTypeExtension.php
It's a lot like looking for a needle in a haystack :8ball:
I would like to thank you for your time (it's not the first time..)
Now I have to see who I can disable this for your bundle..
Just in case someone is having the same problem.. Add this to your conf:
mopa_bootstrap:
form:
show_legend: false # default is true
But I still have to find out how I can configure that just for the FOS bundle... I let you know when I find out..
Overwrite/extend the FOSUserBundle Views and set a custom Form theme where legend is disabled.
Hi,
My question could seem a little candid, but I am wondering why all my forms get translated except for the form legend.
see source:
Twig template:
source: https://github.com/mylen/EventFlowAnalyser/blob/master/app/Resources/FOSUserBundle/views/layout.html.twig
I have been looking around for one hour before asking... I found that: https://github.com/phiamo/MopaBootstrapBundle/issues/275
But I would love not to extends all your nice forms :8ball: