Skip to content

Shortening the "Prototype" paragraph #13445

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 3, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 5 additions & 8 deletions form/form_collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -242,16 +242,13 @@ great, your user can't actually add any new tags yet.
Allowing "new" Tags with the "Prototype"
----------------------------------------

Allowing the user to dynamically add new tags means that you'll need to
use some JavaScript. Previously you added two tags to your form in the controller.
Now let the user add as many tag forms as they need directly in the browser.
Previously we added two dummy tags to our task in the controller.
Now let the users add as many tag forms as they need directly in the browser.
This will be done through a bit of JavaScript.

The first thing you need to do is to let the form collection know that it will
receive an unknown number of tags. So far you've added two tags and the form
type expects to receive exactly two, otherwise an error will be thrown:
``This form should not contain extra fields``. To make this flexible,
add the ``allow_add`` option to your collection field::
But first, we need to let the form collection know that instead of exactly two,
it will receive an *unknown* number of tags. This is done with the
``allow_add`` option::

// src/AppBundle/Form/TaskType.php

Expand Down