Answer the question
In order to leave comments, you need to log in
Is password_widget in Symfony messing up the whole system?
So. How it all happened:
1. I dealt with form customization in Symfony https://symfony.com/doc/current/form/form_customization .
Came up with examples like this.
{% block text_widget %}
<div class="form-control">
{{ block('form_widget_simple') }}
</div>
{% endblock %}
{% block password_widget %}
<div class="form-control">
{{ block('password_widget') }}
</div>
{% endblock %}
{% block password_row %}
<div>
{{ block('form_label') }}
<div class="form-control">
{{ block('password_widget') }}
</div>
</div>
{% endblock %}
<?php
namespace App\Form;
use App\Entity\User;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
use Symfony\Component\Form\Extension\Core\Type\PasswordType;
class UserType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('email', EmailType::class)
->add('username', TextType::class)
->add('plainPassword', RepeatedType::class, array(
'type' => PasswordType::class,
'first_options' => array('label' => 'Password'),
'second_options' => array('label' => 'Repeat Password'),
))
;
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults([
'data_class' => User::class,
]);
}
}
{% extends 'base.html.twig' %}
{% form_theme form _self %}
{% block password_widget %}
<div class="form-control">
{{ block('password_widget') }}
</div>
{% endblock %}
{% block body %}
<div class="form-control col-md-6">
{{ form_start(form) }}
<div>
{{ form_label(form.username) }}:
{{ form_errors(form.username) }}
{{ form_widget(form.username) }}
{{ form_help(form.username) }}
</div>
{{ form_row(form.email) }}
{{ form_row(form.plainPassword.first) }}
{{ form_row(form.plainPassword.second) }}
<button type="submit">Register!</button>
{{ form_end (form) }}
</div>
{% endblock %}
Answer the question
In order to leave comments, you need to log in
Congratulations, now you know what recursion is :)
{% block password_widget %}
<div class="form-control">
{{ block('password_widget') }}
</div>
{% endblock %}
{% form_theme form _self %}
{% block password_widget %}
<div class="form-control">
{{ block('password_widget') }}
</div>
{% endblock %}
{% block password_widget %}
<div class="form-control">
{%- set type = type|default('password') -%}
{{ block('form_widget_simple') }}
</div>
{% endblock %}
FrameworkBundle/Resources/views/Form
templates for php forms are in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question