' . htmlentities($term['label'], ENT_HTML5) . ''; } public function buildForm(FormBuilderInterface $builder, array $options) { $terms = $options['terms']; if (count($terms) > 1) { $lastItem = ' and ' . self::generateTermLink(array_pop($terms)); } else { $lastItem = ''; } $termsString = implode(', ', array_map([ self::class, 'generateTermLink' ], $terms)) . $lastItem; $builder->add('accept', CheckboxType::class, [ 'label' => 'I accept ' . $termsString, 'attr' => [ 'align_with_widget' => true ], 'constraints' => [ new IsTrue([ 'message' => 'You must accept.' ]) ] ]); } /** * * {@inheritdoc} * @see \Symfony\Component\Form\AbstractType::configureOptions() */ public function configureOptions(\Symfony\Component\OptionsResolver\OptionsResolver $resolver) { $resolver->setDefined('terms') ->setRequired('terms') ->addAllowedTypes('terms', 'array') ->setDefault('label', false); } }