【问题标题】:Double textarea? Symfony 2 with FOSU双文本区域? Symfony 2 与 FOSU
【发布时间】:2016-02-26 02:50:50
【问题描述】:

我有这个奇怪的问题,我真的不知道为什么会这样。 文本区域加倍,它们的位置不好。 看图。

所以,构建器看起来像:

public function buildForm(FormBuilderInterface $builder, array $options)
{
    $builder
        ->add('imie', 'text', array('label' => false, 'translation_domain' => 'FOSUserBundle'))
        ->add('nazwisko', 'text', array('label' => false, 'translation_domain' => 'FOSUserBundle'))
        ->add('username', null, array('label' => false, 'translation_domain' => 'FOSUserBundle'))
        ->add('email', 'email', array('label' => false, 'translation_domain' => 'FOSUserBundle'))
        ->add('telefon', 'number', array('label' => false, 'translation_domain' => 'FOSUserBundle'))
        ->add('plainPassword', 'repeated', array(
            'type' => 'password',
            'options' => array('translation_domain' => 'FOSUserBundle'),
            'first_options' => array('label' => false),
            'second_options' => array('label' => false),
            'invalid_message' => 'fos_user.password.mismatch',
        ))
        ->add('captcha', 'captcha', array(
            'label' => ' ',
            'width' => 200,
            'height' => 50,
            'length' => 6,
            'invalid_message' => 'The captcha code is invalid.'
        ))
    ;
}

和 html.twig

http://pastebin.com/2pbHqNyH

请注意,我将 symfony 与 twig 一起使用了 2 周,而且我是初学者。我也是 FOSU 的新手。我只想将注册表单的默认外观从 FOSU 更改为适合我的站点。

【问题讨论】:

    标签: forms symfony twig textarea fosuserbundle


    【解决方案1】:

    那是因为你的repeated密码包含2个字段,所以plainPassword字段渲染包含无效的css结构。

    替换:

    <div class="form-group">
        {{ form_label(form.plainPassword, 'Hasło:', {'label_attr': {'class': 'col-sm-3 control-label'}}) }}
        <div class="col-sm-5">
            {{ form_widget(form.plainPassword, {'attr': {'class':'form-control' }}) }}
            {{ form_errors(form.plainPassword) }}
        </div>
    </div>
    

    作者:

    <div class="form-group">
        {{ form_label(form.plainPassword.first, 'Hasło:', {'label_attr': {'class': 'col-sm-3 control-label'}}) }}
        <div class="col-sm-5">
            {{ form_widget(form.plainPassword.first, {'attr': {'class':'form-control' }}) }}
            {{ form_errors(form.plainPassword.first) }}
        </div>
    </div>
    
    <div class="form-group">
        {{ form_label(form.plainPassword.second, 'Hasło:', {'label_attr': {'class': 'col-sm-3 control-label'}}) }}
        <div class="col-sm-5">
            {{ form_widget(form.plainPassword.second, {'attr': {'class':'form-control' }}) }}
            {{ form_errors(form.plainPassword.second) }}
        </div>
    </div>
    

    更多详情:http://symfony.com/doc/current/reference/forms/types/repeated.html

    【讨论】:

    • 哦,这就是我要找的东西!谢谢!它现在就像一个魅力:)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-06-08
    • 1970-01-01
    • 2013-03-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-10-15
    相关资源
    最近更新 更多