-
-
Notifications
You must be signed in to change notification settings - Fork 399
UX FormCollection #90
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
30 commits
Select commit
Hold shift + click to select a range
ae5d325
UX FormCollection
stakovicz c305f0c
Remove hard coded property_name __name__
stakovicz 5e6dd84
PHP CS Fixer
stakovicz eea2313
First jests
stakovicz f651d90
Rename CollectionType > UXCollectionType
stakovicz cc02076
Rename CollectionType > UXCollectionType
stakovicz dceb2cf
DependencyInjection Clean
stakovicz dfb54f8
Fix .gitattributes
stakovicz 9300cda
Move default values
stakovicz ec4342a
Predefined theme or not
stakovicz b4f40cd
Update src/FormCollection/README.md
stakovicz 0584757
Update src/FormCollection/README.md
stakovicz abd2b8f
Update src/FormCollection/README.md
stakovicz 3996f3b
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz aaa6811
Update src/FormCollection/README.md
stakovicz 4791ff9
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz 8539ff9
Split in 4 options
stakovicz 2d1ed04
Default startIndex value
stakovicz 1e3105d
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz 0a9cc54
Update src/FormCollection/Resources/views/form_theme_div.html.twig
stakovicz 94be94c
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz c805c0e
Update src/FormCollection/Resources/views/form_theme_table.html.twig
stakovicz e56d04b
Fix coding-style-js
stakovicz 7467cee
Prettier
stakovicz a8c730c
Merge branch 'symfony:2.x' into main
stakovicz ecd774a
Merge branch 'symfony:2.x' into main
stakovicz 25d8306
Rebase and refresh the code
stakovicz 8e5cd8a
fix TU
stakovicz 3b110f9
change buttons attr
stakovicz c36157c
Merge branch 'symfony:2.x' into main
stakovicz 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
Prettier
- Loading branch information
commit 7467cee7fe083f8bd167d29df554840385a1d89c
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 |
|---|---|---|
|
|
@@ -27,14 +27,14 @@ You need to select the right theme from the one you are using: | |
| ```yaml | ||
| # config/packages/twig.yaml | ||
| twig: | ||
| # For bootstrap for example | ||
| form_themes: ['@FormCollection/form_theme_div.html.twig'] | ||
| # For bootstrap for example | ||
| form_themes: ['@FormCollection/form_theme_div.html.twig'] | ||
| ``` | ||
|
|
||
| There are 2 predefined themes available: | ||
|
|
||
| - `@FormCollection/form_theme_div.html.twig` | ||
| - `@FormCollection/form_theme_table.html.twig` | ||
| - `@FormCollection/form_theme_div.html.twig` | ||
| - `@FormCollection/form_theme_table.html.twig` | ||
|
|
||
| [Check the Symfony doc](https://symfony.com/doc/4.4/form/form_themes.html) for the different ways to set themes in Symfony. | ||
|
|
||
|
|
@@ -92,11 +92,11 @@ class BlogFormType extends AbstractType | |
| ->add('comments', UXCollectionType::class, [ | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To be as helpful as possible, I think we need to show the user a simple Overall, this is how my example looks locally - I think these options are helpful to all show! 'allow_add' => true,
'allow_delete' => true,
'entry_type' => FileType::class,
// ideally UXCollectionType can set this for us
'by_reference' => false,
'entry_options' => [
// hides the "0", "1", "2" labels on the embedded forms
'label' => false,
],
'button_add_options' => [
'label' => '<span class="fa fa-plus"></span>',
'label_html' => true,
'class' => 'btn btn-secondary btn-sm'
],
'button_delete_options' => [
'label' => '<span class="fa fa-times"></span>',
'label_html' => true,
'class' => 'btn btn-danger btn-sm'
], |
||
| // ... | ||
| // Default text for the add button (used by predefined theme) | ||
| 'button_add_text' => 'Add', | ||
| 'button_add_text' => 'Add', | ||
| // Add HTML classes to the add button (used by predefined theme) | ||
| 'button_add_class' => 'btn btn-outline-primary', | ||
stakovicz marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| // Default text for the delete button (used by predefined theme) | ||
| 'button_delete_text' => 'Remove', | ||
| 'button_delete_text' => 'Remove', | ||
| // Add HTML classes to the add button (used by predefined theme) | ||
| 'button_delete_class' => 'btn btn-outline-secondary', | ||
| ]) | ||
|
|
@@ -147,7 +147,7 @@ export default class extends Controller { | |
|
|
||
| _onPreConnect(event) { | ||
| // The collection is not yet connected | ||
| console.log(event.detail.allowAdd); // Access to the allow_add option of the form | ||
| console.log(event.detail.allowAdd); // Access to the allow_add option of the form | ||
| console.log(event.detail.allowDelete); // Access to the allow_delete option of the form | ||
| } | ||
|
|
||
|
|
@@ -156,7 +156,7 @@ export default class extends Controller { | |
| } | ||
|
|
||
| _onPreAdd(event) { | ||
| console.log(event.detail.index); // Access to the curent index will be added | ||
| console.log(event.detail.index); // Access to the curent index will be added | ||
| console.log(event.detail.element); // Access to the element will be added | ||
| } | ||
|
|
||
|
|
@@ -165,7 +165,7 @@ export default class extends Controller { | |
| } | ||
|
|
||
| _onPreDelete(event) { | ||
| console.log(event.detail.index); // Access to the index will be removed | ||
| console.log(event.detail.index); // Access to the index will be removed | ||
| console.log(event.detail.element); // Access to the elemnt will be removed | ||
| } | ||
|
|
||
|
|
@@ -183,8 +183,8 @@ Then in your render call, add your controller as an HTML attribute: | |
| ->add('comments', UXCollectionType::class, [ | ||
| // ... | ||
| 'attr' => [ | ||
| // Change the controller name | ||
| 'data-controller' => 'mycollection' | ||
| // Change the controller name | ||
| 'data-controller' => 'mycollection' | ||
| ] | ||
| ]); | ||
| ``` | ||
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
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.
I think we should only have one form theme (
form_theme_div.html.twig). If we DID have a 2nd form theme, I would make it a bootstrap theme so that the user could instantly get something nice-looking inside of Bootstrap... but I'm not sure that's necessary because it's really easy to addbtn btn-primaryclasses to the buttons from within the form.Anyways, if the user needs to heavily customize their buttons, let's let them create their own form theme to override our's. Also, I think we should prevent the user from needing to do this step at all. We can automatically add this form theme for them:
ux/src/Dropzone/DependencyInjection/DropzoneExtension.php
Lines 27 to 37 in 09c9eff
PrependExtensionInterface.