parent
fbdcc5415b
commit
2e4ab279d2
@ -0,0 +1,43 @@ |
||||
<?php |
||||
|
||||
declare(strict_types=1); |
||||
|
||||
/* For licensing terms, see /license.txt */ |
||||
|
||||
namespace Chamilo\CoreBundle\Form; |
||||
|
||||
use Symfony\Component\Form\AbstractType; |
||||
use Symfony\Component\Form\Extension\Core\Type\PasswordType; |
||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType; |
||||
use Symfony\Component\Form\FormBuilderInterface; |
||||
use Symfony\Component\OptionsResolver\OptionsResolver; |
||||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; |
||||
|
||||
class ChangePasswordType extends AbstractType |
||||
{ |
||||
public function buildForm(FormBuilderInterface $builder, array $options): void |
||||
{ |
||||
$builder |
||||
->add('currentPassword', PasswordType::class, [ |
||||
'label' => 'Current Password', |
||||
'required' => true, |
||||
]) |
||||
->add('newPassword', PasswordType::class, [ |
||||
'label' => 'New Password', |
||||
'required' => true, |
||||
]) |
||||
->add('confirmPassword', PasswordType::class, [ |
||||
'label' => 'Confirm New Password', |
||||
'required' => true, |
||||
]); |
||||
} |
||||
|
||||
public function configureOptions(OptionsResolver $resolver): void |
||||
{ |
||||
$resolver->setDefaults([ |
||||
'csrf_protection' => true, |
||||
'csrf_field_name' => '_token', |
||||
'csrf_token_id' => 'change_password', |
||||
]); |
||||
} |
||||
} |
@ -0,0 +1,48 @@ |
||||
{% extends "@ChamiloCore/Layout/layout_one_col.html.twig" %} |
||||
|
||||
{% block content %} |
||||
<section id="change-password" class="py-8"> |
||||
<div class="mx-auto w-full"> |
||||
<h2 class="text-2xl font-semibold text-center mb-6">{{ "Change Password"|trans }}</h2> |
||||
|
||||
{{ form_start(form, {'attr': {'class': 'bg-white shadow-md rounded px-8 pt-6 pb-8 mb-4'}}) }} |
||||
|
||||
{% for message in app.flashes('success') %} |
||||
<div class="alert alert-success"> |
||||
{{ message }} |
||||
</div> |
||||
{% endfor %} |
||||
|
||||
{% if form.vars.errors|length > 0 %} |
||||
<div class="alert alert-danger"> |
||||
{{ form_errors(form) }} |
||||
</div> |
||||
{% endif %} |
||||
|
||||
<div class="mb-4"> |
||||
{{ form_label(form.currentPassword) }} |
||||
{{ form_widget(form.currentPassword, {'attr': {'class': 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline'}}) }} |
||||
{{ form_errors(form.currentPassword) }} |
||||
</div> |
||||
|
||||
<div class="mb-4"> |
||||
{{ form_label(form.newPassword) }} |
||||
{{ form_widget(form.newPassword, {'attr': {'class': 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline'}}) }} |
||||
{{ form_errors(form.newPassword) }} |
||||
</div> |
||||
|
||||
<div class="mb-4"> |
||||
{{ form_label(form.confirmPassword) }} |
||||
{{ form_widget(form.confirmPassword, {'attr': {'class': 'shadow appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none focus:shadow-outline'}}) }} |
||||
{{ form_errors(form.confirmPassword) }} |
||||
</div> |
||||
|
||||
<div class="flex items-center justify-center"> |
||||
<input type="hidden" name="_token" value="{{ csrf_token('change_password') }}"> |
||||
<button type="submit" class="btn btn--primary mt-4">{{ "Change Password"|trans }}</button> |
||||
</div> |
||||
|
||||
{{ form_end(form) }} |
||||
</div> |
||||
</section> |
||||
{% endblock %} |
Loading…
Reference in new issue