You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
1.2 KiB
39 lines
1.2 KiB
7 years ago
|
<?php
|
||
|
namespace vierbergenlars\AuthserverTosBundle\Form;
|
||
|
|
||
|
use Symfony\Component\Form\AbstractType;
|
||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||
|
use Symfony\Component\Validator\Constraints\IsTrue;
|
||
|
|
||
|
class AcceptTosType extends AbstractType
|
||
|
{
|
||
|
|
||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
|
{
|
||
|
$builder->add('accept', CheckboxType::class, [
|
||
|
'label' => 'I accept the <a href="' . htmlentities($options['url'], ENT_HTML5 | ENT_QUOTES) . '">terms of service</a>',
|
||
|
'attr' => [
|
||
|
'align_with_widget' => true
|
||
|
],
|
||
|
'constraints' => [
|
||
|
new IsTrue([
|
||
|
'message' => 'You must accept the terms of service.'
|
||
|
])
|
||
|
]
|
||
|
]);
|
||
|
}
|
||
|
|
||
|
/**
|
||
|
*
|
||
|
* {@inheritdoc}
|
||
|
* @see \Symfony\Component\Form\AbstractType::configureOptions()
|
||
|
*/
|
||
|
public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver)
|
||
|
{
|
||
|
$resolver->setDefined('url')
|
||
|
->setRequired('url')
|
||
|
->addAllowedTypes('url', 'string')
|
||
|
->setDefault('label', false);
|
||
|
}
|
||
|
}
|