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.
This repo is archived. You can view files and clone it, but cannot push or open issues/pull-requests.
 
 
tos/Form/AcceptTosType.php

39 lines
1.2 KiB

<?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);
}
}