Cover of the book Symfony 5: The Fast Track

Symfony 5: The Fast Track is the best book to learn modern Symfony development, from zero to production. +300 pages in full color showing how to combine Symfony with Docker, APIs, queues & async tasks, Webpack, Single-Page Applications, etc.

Buy printed version

Form Types

1.3 version
Maintained

Form Types

Checkbox URL Label

The form type cmf_core_checkbox_url_label is based on the checkbox type and adds features useful for the classical “accept terms” check. The difference to a normal checkbox is that the label is linked to a document, typically a “terms and conditions” document. When using this type, you additionally specify content_ids, which are understood by the DynamicRouter, along with replacement tokens:

$form->add('terms', 'cmf_core_checkbox_url_label', array(
    'label' => 'I have seen the <a href="%team%">Team</a> and <a href="%more%">More</a> pages ...',
    'content_ids' => array(
        '%team%' => '/cms/content/static/team',
        '%more%' => '/cms/content/static/more',
    ),
));

The form type automatically generates the routes for the specified content and passes the routes to the trans Twig helper for replacement in the label.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.