-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[2.3] [Form] Support buttons in forms #6528
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
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
cc2118d
[Form] Implemented support for buttons
webmozart 7b438a8
[Form] Made submit buttons able to convey validation groups
webmozart 7b07925
[Form] Changed isset() to array_key_exists() to be consistent with Pa…
webmozart 277d6df
[Form] Fixed concatenation operator CS (see 7c47e34928c39e4797edc8414…
webmozart 600007b
[Form] The option "validation_groups" can now be set to false to disa…
webmozart 0bc7129
[Form] Fixed invalid use of FormException
webmozart ce29c70
[Form] Fixed incorrect doc comment
webmozart 36ca056
[Form] Simplified Twig code
webmozart c8afa88
[Form] Removed deprecated code scheduled for removal in 2.3
webmozart d504732
[Form] Added leading backslashes to @exceptionMessage doc blocks
webmozart faf8d7a
[Form] Added upgrade information about setting "validation_groups" =>…
webmozart File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
UPGRADE FROM 2.2 to 2.3 | ||
======================= | ||
|
||
### Form | ||
|
||
* Although this was not officially supported nor documented, it was possible to | ||
set the option "validation_groups" to false, resulting in the group "Default" | ||
being validated. Now, if you set "validation_groups" to false, the validation | ||
of a form will be skipped (except for a few integrity checks on the form). | ||
|
||
If you want to validate a form in group "Default", you should either | ||
explicitly set "validation_groups" to "Default" or alternatively set it to | ||
null. | ||
|
||
Before: | ||
|
||
``` | ||
// equivalent notations for validating in group "Default" | ||
"validation_groups" => null | ||
"validation_groups" => "Default" | ||
"validation_groups" => false | ||
|
||
// notation for skipping validation | ||
"validation_groups" => array() | ||
``` | ||
|
||
After: | ||
|
||
``` | ||
// equivalent notations for validating in group "Default" | ||
"validation_groups" => null | ||
"validation_groups" => "Default" | ||
|
||
// equivalent notations for skipping validation | ||
"validation_groups" => false | ||
"validation_groups" => array() | ||
``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_attributes.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
id="<?php echo $view->escape($id) ?>" | ||
name="<?php echo $view->escape($full_name) ?>" | ||
<?php if ($disabled): ?>disabled="disabled" <?php endif ?> | ||
<?php foreach ($attr as $k => $v): ?> | ||
<?php printf('%s="%s" ', $view->escape($k), $view->escape($v)) ?> | ||
<?php endforeach; ?> |
Empty file.
3 changes: 3 additions & 0 deletions
3
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_row.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<div> | ||
<?php echo $view['form']->widget($form) ?> | ||
</div> |
4 changes: 4 additions & 0 deletions
4
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/button_widget.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
<?php if (!$label) { $label = $view['form']->humanize($name); } ?> | ||
<button type="<?php echo isset($type) ? $view->escape($type) : 'button' ?>" <?php echo $view['form']->block($form, 'button_attributes') ?>> | ||
<?php $view->escape($view['translator']->trans($label, array(), $translation_domain)) ?> | ||
</button> |
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_enctype.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_errors.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_label.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_rest.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_row.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_rows.html.php
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/field_widget.html.php
This file was deleted.
Oops, something went wrong.
1 change: 1 addition & 0 deletions
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/reset_widget.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php echo $view['form']->block($form, 'button_widget', array('type' => isset($type) ? $type : 'reset')) ?> |
1 change: 1 addition & 0 deletions
1
src/Symfony/Bundle/FrameworkBundle/Resources/views/Form/submit_widget.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<?php echo $view['form']->block($form, 'button_widget', array('type' => isset($type) ? $type : 'submit')) ?> |
6 changes: 6 additions & 0 deletions
6
src/Symfony/Bundle/FrameworkBundle/Resources/views/FormTable/button_row.html.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<tr> | ||
<td></td> | ||
<td> | ||
<?php echo $view['form']->widget($form) ?> | ||
</td> | ||
</tr> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also need to register the Validator SubmitButtonTypeExtension
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can I use if $form->get('clickme') == null to check if this exist or not ?
if ($form->get('clickme') != null && $form->get('clickme')->isClicked()) {
// do stuff
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@josephzhao
$form->get()
will throw an exception in case the child does not exist. This is why we have$form->has()