├── .gitignore ├── .php_cs ├── LICENSE ├── README.md ├── app ├── .htaccess ├── AppCache.php ├── AppKernel.php ├── Resources │ ├── SensioGeneratorBundle │ │ └── skeleton │ │ │ └── crud │ │ │ └── views │ │ │ ├── edit.html.twig.twig │ │ │ ├── index.html.twig.twig │ │ │ ├── new.html.twig.twig │ │ │ ├── others │ │ │ └── record_actions.html.twig.twig │ │ │ └── show.html.twig.twig │ ├── TwigBundle │ │ └── views │ │ │ └── Exception │ │ │ ├── error.html.twig │ │ │ ├── error403.html.twig │ │ │ ├── error404.html.twig │ │ │ └── error500.html.twig │ ├── translations │ │ ├── messages.en.xlf │ │ └── messages.fr.xlf │ └── views │ │ ├── base.html.twig │ │ └── default │ │ └── index.html.twig ├── SymfonyRequirements.php ├── autoload.php ├── check.php ├── config │ ├── config.yml │ ├── config_dev.yml │ ├── config_prod.yml │ ├── config_test.yml │ ├── parameters.yml.dist │ ├── routing.yml │ ├── routing_dev.yml │ ├── security.yml │ └── services.yml ├── console ├── logs │ └── .gitkeep └── phpunit.xml.dist ├── composer.json ├── composer.lock ├── src ├── .htaccess └── Fuz │ ├── AppBundle │ ├── Base │ │ └── BaseController.php │ ├── Controller │ │ ├── Advanced │ │ │ └── FormWithSeveralCollectionsController.php │ │ ├── AdvancedController.php │ │ ├── Basic │ │ │ ├── InATableController.php │ │ │ ├── PositionFieldController.php │ │ │ └── SimpleCollectionController.php │ │ ├── Home │ │ │ └── HomeController.php │ │ ├── OptionsController.php │ │ └── TroubleshootController.php │ ├── DependencyInjection │ │ ├── Configuration.php │ │ └── FuzAppExtension.php │ ├── Entity │ │ ├── Address.php │ │ ├── Addresses.php │ │ ├── Advanced │ │ │ └── FormWithSeveralCollections │ │ │ │ ├── City.php │ │ │ │ ├── Hobby.php │ │ │ │ └── Travel.php │ │ ├── Basic │ │ │ ├── InATable │ │ │ │ ├── Discount.php │ │ │ │ └── DiscountCollection.php │ │ │ └── PositionField │ │ │ │ ├── Action.php │ │ │ │ └── Actions.php │ │ ├── Fancy.php │ │ ├── FancyCollection.php │ │ ├── Home │ │ │ └── Fruit.php │ │ ├── MyArray.php │ │ ├── MyElement.php │ │ ├── Task.php │ │ ├── Tasks.php │ │ └── Value.php │ ├── Form │ │ ├── AddressType.php │ │ ├── AddressesType.php │ │ ├── Advanced │ │ │ └── FormWithSeveralCollections │ │ │ │ ├── CityType.php │ │ │ │ ├── HobbyType.php │ │ │ │ └── TravelType.php │ │ ├── Basic │ │ │ ├── InATable │ │ │ │ ├── DiscountCollectionType.php │ │ │ │ └── DiscountType.php │ │ │ └── PositionField │ │ │ │ ├── ActionType.php │ │ │ │ └── ActionsType.php │ │ ├── FancyCollectionType.php │ │ ├── FancyType.php │ │ ├── Home │ │ │ └── FruitType.php │ │ ├── MyArrayType.php │ │ ├── MyElementType.php │ │ ├── TaskType.php │ │ ├── TasksType.php │ │ └── ValueType.php │ ├── FuzAppBundle.php │ ├── Menu │ │ └── Builder.php │ ├── Repository │ │ └── MyArrayRepository.php │ ├── Resources │ │ ├── config │ │ │ └── services.xml │ │ ├── translations │ │ │ ├── messages.en.xlf │ │ │ └── messages.fr.xlf │ │ └── views │ │ │ ├── Advanced │ │ │ ├── FormWithSeveralCollections │ │ │ │ ├── form-theme.html.twig │ │ │ │ └── index.html.twig │ │ │ ├── addresses-theme.html.twig │ │ │ ├── advanced-theme.html.twig │ │ │ ├── collectionOfCollections.html.twig │ │ │ ├── customFormTheme.html.twig │ │ │ ├── customFormThemeAddBottom.html.twig │ │ │ ├── doctrine-theme.html.twig │ │ │ ├── fancy-theme.html.twig │ │ │ ├── fancyFormTheme.html.twig │ │ │ ├── formHavingSeveralFields.html.twig │ │ │ ├── mvcCompliance.html.twig │ │ │ └── usageWithDoctrine.html.twig │ │ │ ├── Basic │ │ │ ├── InATable │ │ │ │ ├── form-theme.html.twig │ │ │ │ └── index.html.twig │ │ │ ├── PositionField │ │ │ │ ├── formTheme.html.twig │ │ │ │ └── positionField.html.twig │ │ │ └── SimpleCollection │ │ │ │ └── simpleCollection.html.twig │ │ │ ├── Home │ │ │ └── Home │ │ │ │ ├── formThemeNoButtons.html.twig │ │ │ │ ├── formThemeWithButtons.html.twig │ │ │ │ └── home.html.twig │ │ │ ├── Options │ │ │ ├── addButtonAtTheBottom.html.twig │ │ │ ├── buttonsCustomLocation.html.twig │ │ │ ├── customButtons.html.twig │ │ │ ├── dragAndDrop.html.twig │ │ │ ├── enableButtons.html.twig │ │ │ ├── eventCallbacks.html.twig │ │ │ ├── fadeInFadeOut.html.twig │ │ │ ├── givenMinimumElements.html.twig │ │ │ ├── hideMoveUpDown.html.twig │ │ │ ├── initCallbacks.html.twig │ │ │ ├── numberCollectionElements.html.twig │ │ │ ├── options-theme.html.twig │ │ │ ├── overview.html.twig │ │ │ └── withoutFormTheme.html.twig │ │ │ ├── Troubleshoot │ │ │ ├── customJqueryVersion.html.twig │ │ │ └── hideFormLabels.html.twig │ │ │ ├── github.html.twig │ │ │ ├── layout.html.twig │ │ │ └── tabs.html.twig │ └── Twig │ │ └── Extension │ │ └── HelperExtension.php │ └── QuickStartBundle │ ├── Base │ ├── BaseCommand.php │ ├── BaseController.php │ ├── BaseMenu.php │ └── BaseService.php │ ├── Controller │ └── ReloadController.php │ ├── DependencyInjection │ ├── Configuration.php │ └── FuzQuickStartExtension.php │ ├── EventListener │ ├── LastRouteListener.php │ └── LocaleListener.php │ ├── FuzQuickStartBundle.php │ ├── Resources │ ├── config │ │ ├── routing.yml │ │ └── services.yml │ ├── public │ │ ├── bootstrap-submenu │ │ │ ├── css │ │ │ │ ├── bootstrap-submenu.css │ │ │ │ ├── bootstrap-submenu.css.map │ │ │ │ └── bootstrap-submenu.min.css │ │ │ └── js │ │ │ │ ├── bootstrap-submenu.js │ │ │ │ └── bootstrap-submenu.min.js │ │ ├── css │ │ │ └── custom.css │ │ ├── img │ │ │ ├── countries │ │ │ │ ├── Afghanistan.png │ │ │ │ ├── Albania.png │ │ │ │ ├── Algeria.png │ │ │ │ ├── American-Samoa.png │ │ │ │ ├── Andorra.png │ │ │ │ ├── Angola.png │ │ │ │ ├── Anguilla.png │ │ │ │ ├── Antigua-and-Barbuda.png │ │ │ │ ├── Argentina.png │ │ │ │ ├── Armenia.png │ │ │ │ ├── Aruba.png │ │ │ │ ├── Australia.png │ │ │ │ ├── Austria.png │ │ │ │ ├── Azerbaijan.png │ │ │ │ ├── Bahrain.png │ │ │ │ ├── Bangladesh.png │ │ │ │ ├── Barbados.png │ │ │ │ ├── Belarus.png │ │ │ │ ├── Belgium.png │ │ │ │ ├── Belize.png │ │ │ │ ├── Benin.png │ │ │ │ ├── Bermuda.png │ │ │ │ ├── Bhutan.png │ │ │ │ ├── Bolivia.png │ │ │ │ ├── Bosnia-and-Herzegovina.png │ │ │ │ ├── Bostswana.png │ │ │ │ ├── Bouvet-Island.png │ │ │ │ ├── Brazil.png │ │ │ │ ├── British-Indian-Ocean-Territory.png │ │ │ │ ├── British-Virgin-Islands.png │ │ │ │ ├── Brunei.png │ │ │ │ ├── Bulgaria.png │ │ │ │ ├── Burkina-Faso.png │ │ │ │ ├── Burma.png │ │ │ │ ├── Burundi.png │ │ │ │ ├── Cambodia.png │ │ │ │ ├── Cameroon.png │ │ │ │ ├── Canada.png │ │ │ │ ├── Cape-Verde.png │ │ │ │ ├── Cayman-Islands.png │ │ │ │ ├── Central-African-Republic.png │ │ │ │ ├── Chad.png │ │ │ │ ├── Chile.png │ │ │ │ ├── China.png │ │ │ │ ├── Christmas-Islands.png │ │ │ │ ├── Cocos-(Keeling)-Islands.png │ │ │ │ ├── Colombia.png │ │ │ │ ├── Comoros.png │ │ │ │ ├── Cook-Islands.png │ │ │ │ ├── Costa-Rica.png │ │ │ │ ├── Cote-d'Ivoire.png │ │ │ │ ├── Croatia.png │ │ │ │ ├── Cuba.png │ │ │ │ ├── Cyprus.png │ │ │ │ ├── Czech-Republic.png │ │ │ │ ├── Democratic-Republic-of-the-Congo.png │ │ │ │ ├── Denmark.png │ │ │ │ ├── Djibouti.png │ │ │ │ ├── Dominica.png │ │ │ │ ├── Dominican-Republic.png │ │ │ │ ├── Ecuador.png │ │ │ │ ├── Egypt.png │ │ │ │ ├── El-Salvador.png │ │ │ │ ├── Equatorial-Guinea.png │ │ │ │ ├── Eritrea.png │ │ │ │ ├── Estonia.png │ │ │ │ ├── Ethiopia.png │ │ │ │ ├── European-Union.png │ │ │ │ ├── Falkland-Islands-(Islas-Malvinas).png │ │ │ │ ├── Faroe-Islands.png │ │ │ │ ├── Fiji.png │ │ │ │ ├── Finland.png │ │ │ │ ├── France.png │ │ │ │ ├── French-Poynesia.png │ │ │ │ ├── Gabon.png │ │ │ │ ├── Georgia.png │ │ │ │ ├── Germany.png │ │ │ │ ├── Ghana.png │ │ │ │ ├── Gibraltar.png │ │ │ │ ├── Greece.png │ │ │ │ ├── Greenland.png │ │ │ │ ├── Grenada.png │ │ │ │ ├── Guam.png │ │ │ │ ├── Guatemala.png │ │ │ │ ├── Guernsey.png │ │ │ │ ├── Guinea-Blissau.png │ │ │ │ ├── Guinea.png │ │ │ │ ├── Guyana.png │ │ │ │ ├── Haiti.png │ │ │ │ ├── Holy-See-(Vatican-City).png │ │ │ │ ├── Honduras.png │ │ │ │ ├── Hong-Kong.png │ │ │ │ ├── Hungary.png │ │ │ │ ├── Iceland.png │ │ │ │ ├── India.png │ │ │ │ ├── Indonesia.png │ │ │ │ ├── Iran.png │ │ │ │ ├── Iraq.png │ │ │ │ ├── Ireland.png │ │ │ │ ├── Isle-of-Man.png │ │ │ │ ├── Israel.png │ │ │ │ ├── Italy.png │ │ │ │ ├── Jamaica.png │ │ │ │ ├── Japan.png │ │ │ │ ├── Jordan.png │ │ │ │ ├── Kazahstan.png │ │ │ │ ├── Kenya.png │ │ │ │ ├── Kiribati.png │ │ │ │ ├── Kosovo.png │ │ │ │ ├── Kuwait.png │ │ │ │ ├── Kyrgyzstan.png │ │ │ │ ├── Laos.png │ │ │ │ ├── Latvia.png │ │ │ │ ├── Lebanon.png │ │ │ │ ├── Lesotho.png │ │ │ │ ├── Liberia.png │ │ │ │ ├── Libya.png │ │ │ │ ├── Liechtenstein.png │ │ │ │ ├── Lithuania.png │ │ │ │ ├── Luxembourg.png │ │ │ │ ├── Macau.png │ │ │ │ ├── Macedonia.png │ │ │ │ ├── Madagascar.png │ │ │ │ ├── Malawi.png │ │ │ │ ├── Malaysia.png │ │ │ │ ├── Maldives.png │ │ │ │ ├── Mali.png │ │ │ │ ├── Malta.png │ │ │ │ ├── Marschal-Islands.png │ │ │ │ ├── Mauritania.png │ │ │ │ ├── Mauritius.png │ │ │ │ ├── Mayotte.png │ │ │ │ ├── Mexico.png │ │ │ │ ├── Micronesia.png │ │ │ │ ├── Moldavia.png │ │ │ │ ├── Monaco.png │ │ │ │ ├── Mongolia.png │ │ │ │ ├── Montenegro.png │ │ │ │ ├── Montserrat.png │ │ │ │ ├── Morocco.png │ │ │ │ ├── Mozambique.png │ │ │ │ ├── Namibia.png │ │ │ │ ├── Nauru.png │ │ │ │ ├── Nepal.png │ │ │ │ ├── Netherlands-Anthilles.png │ │ │ │ ├── Netherlands.png │ │ │ │ ├── New-Zealand.png │ │ │ │ ├── Nicaragua.png │ │ │ │ ├── Niger.png │ │ │ │ ├── Nigeria.png │ │ │ │ ├── Niue.png │ │ │ │ ├── Norfolk-Island.png │ │ │ │ ├── North-Korea.png │ │ │ │ ├── Northern-Mariana-Islands.png │ │ │ │ ├── Norway.png │ │ │ │ ├── Oman.png │ │ │ │ ├── Pakistan.png │ │ │ │ ├── Palau.png │ │ │ │ ├── Panama.png │ │ │ │ ├── Papua-New-Guinea.png │ │ │ │ ├── Paraguay.png │ │ │ │ ├── Peru.png │ │ │ │ ├── Philippines.png │ │ │ │ ├── Pitcairn-Islands.png │ │ │ │ ├── Poland.png │ │ │ │ ├── Portugal.png │ │ │ │ ├── Puerto-Rico.png │ │ │ │ ├── Quatar.png │ │ │ │ ├── Republic-of-the-Congo.png │ │ │ │ ├── Romania.png │ │ │ │ ├── Russia.png │ │ │ │ ├── Rwanda.png │ │ │ │ ├── Saint-Helena.png │ │ │ │ ├── Saint-Kitts-and-Nevis.png │ │ │ │ ├── Saint-Lucia.png │ │ │ │ ├── Saint-Pierre-and-Miquelon.png │ │ │ │ ├── Saint-Vincent.png │ │ │ │ ├── Samoa.png │ │ │ │ ├── San-Marino.png │ │ │ │ ├── Sao-Tome-and-Principe.png │ │ │ │ ├── Saudi-Arabia.png │ │ │ │ ├── Senegal.png │ │ │ │ ├── Seychelles.png │ │ │ │ ├── Sierra-Leone.png │ │ │ │ ├── Singapore.png │ │ │ │ ├── Slovakia.png │ │ │ │ ├── Slovenia.png │ │ │ │ ├── Solomon-Islands.png │ │ │ │ ├── Somalia.png │ │ │ │ ├── South-Africa.png │ │ │ │ ├── South-Georgia-and-the-South-Sandwitch-Islands.png │ │ │ │ ├── South-Korea.png │ │ │ │ ├── Spain.png │ │ │ │ ├── Sri-Lanka.png │ │ │ │ ├── Sudan.png │ │ │ │ ├── Suriname.png │ │ │ │ ├── Swaziland.png │ │ │ │ ├── Sweden.png │ │ │ │ ├── Switzerland.png │ │ │ │ ├── Syria.png │ │ │ │ ├── Taiwan.png │ │ │ │ ├── Tajikistan.png │ │ │ │ ├── Tanzania.png │ │ │ │ ├── Thailand.png │ │ │ │ ├── Tibet.png │ │ │ │ ├── Timor-Leste.png │ │ │ │ ├── Togo.png │ │ │ │ ├── Tonga.png │ │ │ │ ├── Trinidad-and-Tobago.png │ │ │ │ ├── Tunisia.png │ │ │ │ ├── Turkey.png │ │ │ │ ├── Turkmenistan.png │ │ │ │ ├── Turks-and-Caicos-Islands.png │ │ │ │ ├── Tuvalu.png │ │ │ │ ├── Uganda.png │ │ │ │ ├── Ukraine.png │ │ │ │ ├── United-Arab-Emirates.png │ │ │ │ ├── United-Kingdom.png │ │ │ │ ├── United-States.png │ │ │ │ ├── Uruguay.png │ │ │ │ ├── Uzbekistan.png │ │ │ │ ├── Vanuatu.png │ │ │ │ ├── Venezuela.png │ │ │ │ ├── Vietnam.png │ │ │ │ ├── Virgin-Islands.png │ │ │ │ ├── Wallis-and-Futuna.png │ │ │ │ ├── Yemen.png │ │ │ │ ├── Zambia.png │ │ │ │ ├── Zimbabwe.png │ │ │ │ ├── the-Bahamas.png │ │ │ │ └── the-Gambia.png │ │ │ ├── flags │ │ │ │ ├── black.gif │ │ │ │ ├── blue.gif │ │ │ │ ├── green.gif │ │ │ │ ├── red.gif │ │ │ │ └── yellow.gif │ │ │ ├── oauth │ │ │ │ ├── facebook-small.png │ │ │ │ ├── facebook.png │ │ │ │ ├── google-small.png │ │ │ │ ├── google.png │ │ │ │ ├── twitter-small.png │ │ │ │ └── twitter.png │ │ │ └── wait.gif │ │ ├── jquery-ui-1.11.2 │ │ │ ├── images │ │ │ │ ├── ui-bg_diagonals-thick_18_b81900_40x40.png │ │ │ │ ├── ui-bg_diagonals-thick_20_666666_40x40.png │ │ │ │ ├── ui-bg_flat_10_000000_40x100.png │ │ │ │ ├── ui-bg_glass_100_f6f6f6_1x400.png │ │ │ │ ├── ui-bg_glass_100_fdf5ce_1x400.png │ │ │ │ ├── ui-bg_glass_65_ffffff_1x400.png │ │ │ │ ├── ui-bg_gloss-wave_35_f6a828_500x100.png │ │ │ │ ├── ui-bg_highlight-soft_100_eeeeee_1x100.png │ │ │ │ ├── ui-bg_highlight-soft_75_ffe45c_1x100.png │ │ │ │ ├── ui-icons_222222_256x240.png │ │ │ │ ├── ui-icons_228ef1_256x240.png │ │ │ │ ├── ui-icons_ef8c08_256x240.png │ │ │ │ ├── ui-icons_ffd27a_256x240.png │ │ │ │ └── ui-icons_ffffff_256x240.png │ │ │ ├── index.html │ │ │ ├── jquery-ui.css │ │ │ ├── jquery-ui.js │ │ │ ├── jquery-ui.min.css │ │ │ ├── jquery-ui.min.js │ │ │ ├── jquery-ui.structure.css │ │ │ ├── jquery-ui.structure.min.css │ │ │ ├── jquery-ui.theme.css │ │ │ └── jquery-ui.theme.min.css │ │ └── js │ │ │ ├── jquery-2.1.1.min.js │ │ │ └── jquery.domajax.js │ ├── translations │ │ ├── messages.en.xlf │ │ └── messages.fr.xlf │ └── views │ │ ├── base-ajax.html.twig │ │ ├── base.html.twig │ │ ├── knp_menu.html.twig │ │ ├── layout.html.twig │ │ └── macros.html.twig │ ├── Services │ └── Routing.php │ └── Tools │ └── Math.php └── web ├── .htaccess ├── app.php ├── app_dev.php ├── apple-touch-icon.png ├── config.php ├── favicon.ico └── robots.txt /.gitignore: -------------------------------------------------------------------------------- 1 | nbproject 2 | web/bundles/ 3 | web/js 4 | web/css 5 | web/fonts 6 | app/bootstrap.php.cache 7 | app/cache/* 8 | app/config/parameters.yml 9 | app/Resources/views/jquery.collection.html.twig 10 | app/logs/* 11 | !app/cache/.gitkeep 12 | !app/logs/.gitkeep 13 | build/ 14 | vendor/ 15 | bin/ 16 | composer.phar 17 | TODO 18 | .php_cs.cache 19 | .web-server-pid 20 | 21 | -------------------------------------------------------------------------------- /.php_cs: -------------------------------------------------------------------------------- 1 | files() 7 | ->name('*.php') 8 | ->ignoreDotFiles(true) 9 | ->ignoreVCS(true) 10 | ->in($dir) 11 | ->exclude('cache') 12 | ->exclude('logs') 13 | ->exclude('Resources') 14 | ->exclude('vendor') 15 | ; 16 | 17 | return Symfony\CS\Config\Config::create() 18 | ->level(Symfony\CS\FixerInterface::SYMFONY_LEVEL) 19 | ->fixers([ 20 | // remove a few Symfony rules 21 | '-concat_without_spaces', 22 | '-phpdoc_short_description', 23 | '-pre_increment', 24 | 'align_double_arrow', 25 | 'align_equals', 26 | // add a few Contrib rules 27 | 'concat_with_spaces', 28 | 'newline_after_open_tag', 29 | 'ordered_use', 30 | 'phpdoc_order', 31 | 'short_array_syntax' 32 | ]) 33 | ->setUsingCache(true) 34 | ->setUsingLinter(false) 35 | ->finder($finder) 36 | ; -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2004-2014 Fabien Potencier 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy 4 | of this software and associated documentation files (the "Software"), to deal 5 | in the Software without restriction, including without limitation the rights 6 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 7 | copies of the Software, and to permit persons to whom the Software is furnished 8 | to do so, subject to the following conditions: 9 | 10 | The above copyright notice and this permission notice shall be included in all 11 | copies or substantial portions of the Software. 12 | 13 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 14 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 15 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 16 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 17 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 18 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 19 | THE SOFTWARE. 20 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Symfony Collection demo website 2 | ======================== 3 | 4 | ## See this website [live](http://symfony-collection.fuz.org/) 5 | 6 | --- 7 | 8 | ## Installation 9 | 10 | ```sh 11 | php -r "readfile('https://getcomposer.org/installer');" | php 12 | php composer.phar install 13 | php app/console assetic:dump 14 | php app/console assets:install web --symlink 15 | php app/console server:start 16 | ``` 17 | 18 | ## Usage 19 | 20 | All "Basic Usage" samples have their own controllers, form types, views etc. for easier readability. 21 | 22 | If you go to `http://127.0.0.1:8000/basic/positionField`, it means that: 23 | 24 | - Controller is at `AppBundle\Controller\Basic\PositionFieldController.php` 25 | - Entities are at `AppBundle\Entity\Basic\PositionField` 26 | - Form types are at `AppBundle\Form\Basic\PositionField` 27 | - Views and form themes are at `AppBundle\Resources\views\Basic\PositionField` 28 | 29 | Other samples use more generic data because that was quicker to code. If you feel that's not easy enough to understand, 30 | don't hesitate to throw a suggestion or a PR. 31 | 32 | ## License 33 | 34 | - This project is released under the MIT license 35 | 36 | - Fuz logo is © 2013-2042 Alain Tiemblo 37 | 38 | -------------------------------------------------------------------------------- /app/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /app/AppCache.php: -------------------------------------------------------------------------------- 1 | getEnvironment(), array('dev', 'test'))) { 32 | $bundles[] = new Symfony\Bundle\DebugBundle\DebugBundle(); 33 | $bundles[] = new Symfony\Bundle\WebProfilerBundle\WebProfilerBundle(); 34 | $bundles[] = new Sensio\Bundle\DistributionBundle\SensioDistributionBundle(); 35 | $bundles[] = new Sensio\Bundle\GeneratorBundle\SensioGeneratorBundle(); 36 | } 37 | 38 | return $bundles; 39 | } 40 | 41 | public function registerContainerConfiguration(LoaderInterface $loader) 42 | { 43 | $loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml'); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /app/Resources/SensioGeneratorBundle/skeleton/crud/views/edit.html.twig.twig: -------------------------------------------------------------------------------- 1 | {% block extends %} 2 | {{ "{% extends 'AppBundle::layout.html.twig' %}" }} 3 | {% endblock extends %} 4 | 5 | {% block body %} 6 | {{ "{% block body %}" }} 7 |

{{ "{{ 'quickstart.crud.edit.title' | trans({'%entity%': '" ~ entity ~ "'}) }}" }}

8 | 9 | {{ '{{ form_start(edit_form) }}' }} 10 | {{ '{{ form_widget(edit_form) }}' }} 11 | 12 | {{ '{{ form_end(edit_form) }}' }} 13 | 14 | {% set hide_edit, hide_delete = true, false %} 15 | {{ include('crud/views/others/record_actions.html.twig.twig') -}} 16 | {{ "{% endblock %}" }} 17 | {% endblock body %} 18 | -------------------------------------------------------------------------------- /app/Resources/SensioGeneratorBundle/skeleton/crud/views/new.html.twig.twig: -------------------------------------------------------------------------------- 1 | {% block extends %} 2 | {{ "{% extends 'AppBundle::layout.html.twig' %}" }} 3 | {% endblock extends %} 4 | 5 | {% block body %} 6 | {{ "{% block body %}" }} 7 |

{{ "{{ 'quickstart.crud.new.title' | trans({'%entity%': '" ~ entity ~ "'}) }}" }}

8 | 9 | {{ '{{ form_start(form) }}' }} 10 | {{ '{{ form_widget(form) }}' }} 11 | 12 | {{ '{{ form_end(form) }}' }} 13 | 14 | {% set hide_edit, hide_delete = true, true %} 15 | {{ include('crud/views/others/record_actions.html.twig.twig') -}} 16 | {{ "{% endblock %}" }} 17 | {% endblock body %} 18 | -------------------------------------------------------------------------------- /app/Resources/SensioGeneratorBundle/skeleton/crud/views/others/record_actions.html.twig.twig: -------------------------------------------------------------------------------- 1 |
2 | 3 | {% set show_edit = ('edit' in actions) and (not hide_edit) %} 4 | {% set show_delete = ('delete' in actions) and (not hide_delete) %} 5 | {% set nb_buttons = show_edit + show_delete %} 6 | 7 | {% if nb_buttons %} 8 | 9 |
10 | {% if show_edit %} 11 |
12 | {{ "{{ 'quickstart.crud.button.update' | trans }}" }} 13 |
14 | {% endif %} 15 | {% if show_delete %} 16 |
17 | {{ '{{ form_start(delete_form) }}' }} 18 | 19 | {{ '{{ form_end(delete_form) }}' }} 20 |
21 | {% endif %} 22 |
23 | 24 | {% endif %} 25 | 26 |

27 | 28 |
29 | {{ "{{ 'quickstart.crud.back' | trans }}" }} 30 |
-------------------------------------------------------------------------------- /app/Resources/SensioGeneratorBundle/skeleton/crud/views/show.html.twig.twig: -------------------------------------------------------------------------------- 1 | {% block extends %} 2 | {{ "{% extends 'AppBundle::layout.html.twig' %}" }} 3 | {% endblock extends %} 4 | 5 | {% block body %} 6 | {{ "{% block body %}" }} 7 |

{{ entity }}

8 | 9 |
10 | 11 | 12 | 13 | {%- for field, metadata in fields %} 14 | 15 | 16 | 17 | 18 | {%- if metadata.type in ['datetime'] %} 19 | 20 | 21 | 22 | {%- elseif metadata.type in ['date'] %} 23 | 24 | 25 | 26 | {%- elseif metadata.type in ['time'] %} 27 | 28 | 29 | 30 | {%- elseif metadata.type in ['array'] %} 31 | 32 | 33 | 34 | {%- elseif metadata.type in ['boolean'] %} 35 | 36 | 37 | 38 | {%- else %} 39 | 40 | 41 | 42 | {%- endif %} 43 | 44 | 45 | 46 | {%- endfor %} 47 | 48 | 49 |
{{ field|capitalize }}{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'Y-m-d H:i:s\') }}{% endif %}' }}{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'Y-m-d\') }}{% endif %}' }}{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|date(\'H:i:s\') }}{% endif %}' }}{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ '|join(\', \') }}{% endif %}' }}{{ '{% if ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' %}Yes{% else %}No{% endif %}' }}{{ '{{ ' ~ entity_singularized ~ '.' ~ field|replace({'_': ''}) ~ ' }}' }}
50 | 51 | {% set hide_edit, hide_delete = false, false %} 52 | {{ include('crud/views/others/record_actions.html.twig.twig') -}} 53 | {{ "{% endblock %}" }} 54 | {% endblock body %} 55 | -------------------------------------------------------------------------------- /app/Resources/TwigBundle/views/Exception/error.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzQuickStartBundle::layout.html.twig' %} 2 | 3 | {% block menu %}{% endblock %} 4 | {% block login %}{% endblock %} 5 | 6 | {% block title %}{{ status_code }} - {{ status_text | title }}{% endblock %} 7 | 8 | {% block body %} 9 | 10 |
11 |
12 |

{{ status_code }} - {{ status_text | title }}

13 | 14 |
{{ 'quickstart.error.back_sentence' | trans }}
15 | 16 |
 
17 | 18 | 21 | 22 |
23 |
 
24 |
25 | 26 | {% endblock %} 27 | -------------------------------------------------------------------------------- /app/Resources/TwigBundle/views/Exception/error403.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzQuickStartBundle::layout.html.twig' %} 2 | 3 | {% block menu %}{% endblock %} 4 | {% block login %}{% endblock %} 5 | 6 | {% block title %}{{ 'quickstart.error.403.title' | trans | title }}{% endblock %} 7 | 8 | {% block body %} 9 | 10 |
11 |
12 |

403 - {{ 'quickstart.error.403.title' | trans | title }}

13 | 14 |
15 | {{ 'quickstart.error.403.explain' | trans }} 16 |
17 | 18 |
 
19 | 20 |
{{ 'quickstart.error.back_sentence' | trans }}
21 | 22 |
 
23 | 24 | 27 | 28 |
29 |
 
30 |
31 | 32 | {% endblock %} 33 | -------------------------------------------------------------------------------- /app/Resources/TwigBundle/views/Exception/error404.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzQuickStartBundle::layout.html.twig' %} 2 | 3 | {% block menu %}{% endblock %} 4 | {% block login %}{% endblock %} 5 | 6 | {% block title %}{{ 'quickstart.error.404.title' | trans | title }}{% endblock %} 7 | 8 | {% block body %} 9 | 10 |
11 |
12 |

404 - {{ 'quickstart.error.404.title' | trans | title }}

13 | 14 |
{{ 'quickstart.error.404.explain' | trans }}
15 | 16 |
 
17 | 18 |
{{ 'quickstart.error.back_sentence' | trans }}
19 | 20 |
 
21 | 22 | 25 | 26 |
27 |
 
28 |
29 | 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /app/Resources/TwigBundle/views/Exception/error500.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzQuickStartBundle::layout.html.twig' %} 2 | 3 | {% block menu %}{% endblock %} 4 | {% block login %}{% endblock %} 5 | 6 | {% block title %}{{ 'quickstart.error.500.title' | trans | title }}{% endblock %} 7 | 8 | {% block body %} 9 | 10 |
11 |
12 |

500 - {{ 'quickstart.error.500.title' | trans | title }}

13 | 14 |
{{ 'quickstart.error.500.explain' | trans }}
15 | 16 |
 
17 | 18 |
{{ 'quickstart.error.back_sentence' | trans }}
19 | 20 |
 
21 | 22 | 25 | 26 |
27 |
 
28 |
29 | 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /app/Resources/translations/messages.en.xlf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/Resources/translations/messages.fr.xlf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /app/Resources/views/base.html.twig: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | {% block title %}Welcome!{% endblock %} 6 | {% block stylesheets %}{% endblock %} 7 | 8 | 9 | 10 | {% block body %}{% endblock %} 11 | {% block javascripts %}{% endblock %} 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/Resources/views/default/index.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'base.html.twig' %} 2 | 3 | {% block body %} 4 | Homepage. 5 | {% endblock %} 6 | -------------------------------------------------------------------------------- /app/autoload.php: -------------------------------------------------------------------------------- 1 | getParameterOption(['--env', '-e'], getenv('SYMFONY_ENV') ?: 'dev'); 21 | $debug = getenv('SYMFONY_DEBUG') !== '0' && !$input->hasParameterOption(['--no-debug', '']) && $env !== 'prod'; 22 | 23 | if ($debug) { 24 | Debug::enable(); 25 | } 26 | 27 | $kernel = new AppKernel($env, $debug); 28 | $application = new Application($kernel); 29 | $application->run($input); 30 | -------------------------------------------------------------------------------- /app/logs/.gitkeep: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninsuo/symfony-collection-demo/95c610d487b4f7f783187aecdd09fe4e636155d0/app/logs/.gitkeep -------------------------------------------------------------------------------- /app/phpunit.xml.dist: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 10 | 11 | 12 | ../src/*/*Bundle/Tests 13 | ../src/*/Bundle/*Bundle/Tests 14 | ../src/*Bundle/Tests 15 | 16 | 17 | 18 | 23 | 24 | 25 | 26 | ../src 27 | 28 | ../src/*Bundle/Resources 29 | ../src/*Bundle/Tests 30 | ../src/*/*Bundle/Resources 31 | ../src/*/*Bundle/Tests 32 | ../src/*/Bundle/*Bundle/Resources 33 | ../src/*/Bundle/*Bundle/Tests 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /src/.htaccess: -------------------------------------------------------------------------------- 1 | 2 | Require all denied 3 | 4 | 5 | Order deny,allow 6 | Deny from all 7 | 8 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Controller/Basic/InATableController.php: -------------------------------------------------------------------------------- 1 | setProductName('Mug'); 29 | 30 | // 5% discount when buying from 5 to 10 items 31 | $discountA = new Discount(); 32 | $discountA->setQuantityFrom(5); 33 | $discountA->setQuantityTo(10); 34 | $discountA->setDiscount(5); 35 | $discounts->getDiscounts()->add($discountA); 36 | 37 | // 10% discount when buying from 11 to 25 items 38 | $discountB = new Discount(); 39 | $discountB->setQuantityFrom(11); 40 | $discountB->setQuantityTo(25); 41 | $discountB->setDiscount(10); // 10% 42 | $discounts->getDiscounts()->add($discountB); 43 | 44 | // 20% discount when buying from 26 to 99 items 45 | $discountC = new Discount(); 46 | $discountC->setQuantityFrom(26); 47 | $discountC->setQuantityTo(99); 48 | $discountC->setDiscount(20); // 20% 49 | $discounts->getDiscounts()->add($discountC); 50 | 51 | $form = $this->createForm(DiscountCollectionType::class, $discounts); 52 | if ($request->isMethod('POST')) { 53 | $form->handleRequest($request); 54 | } 55 | 56 | return [ 57 | 'form' => $form->createView(), 58 | 'data' => $discounts, 59 | ]; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Controller/Basic/PositionFieldController.php: -------------------------------------------------------------------------------- 1 | setId(42 + $i); // just to distinguish id and position 30 | 31 | switch ($i) { 32 | case 0: 33 | $action->setName('walk the dog'); 34 | break; 35 | case 1: 36 | $action->setName('eat breakfast'); 37 | break; 38 | case 2: 39 | $action->setName('take a shower'); 40 | break; 41 | case 3: 42 | $action->setName('yawn loudly'); 43 | break; 44 | } 45 | 46 | $action->setPosition($i); 47 | 48 | $actions->getActions()->add($action); 49 | } 50 | 51 | $form = $this->createForm(ActionsType::class, $actions); 52 | if ($request->isMethod('POST')) { 53 | $form->handleRequest($request); 54 | } 55 | 56 | return [ 57 | 'form' => $form->createView(), 58 | 'data' => $actions, 59 | ]; 60 | } 61 | } 62 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Controller/Basic/SimpleCollectionController.php: -------------------------------------------------------------------------------- 1 | ['a', 'b', 'c']]; 25 | 26 | $form = $this 27 | ->createFormBuilder($data) 28 | ->add('values', Type\CollectionType::class, [ 29 | 'entry_type' => Type\TextType::class, 30 | 'entry_options' => [ 31 | 'label' => 'Value', 32 | ], 33 | 'label' => 'Add, move, remove values and press Submit.', 34 | 'allow_add' => true, 35 | 'allow_delete' => true, 36 | 'prototype' => true, 37 | 'required' => false, 38 | 'attr' => [ 39 | 'class' => 'my-selector', 40 | ], 41 | ]) 42 | ->add('submit', Type\SubmitType::class) 43 | ->getForm() 44 | ; 45 | 46 | $form->handleRequest($request); 47 | if ($form->isValid()) { 48 | $data = $form->getData(); 49 | } 50 | 51 | return [ 52 | 'form' => $form->createView(), 53 | 'data' => $data, 54 | ]; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | root('fuz_app'); 22 | 23 | // Here you should define the parameters that are allowed to 24 | // configure your bundle. See the documentation linked above for 25 | // more information on that topic. 26 | 27 | return $treeBuilder; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/DependencyInjection/FuzAppExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration($configuration, $configs); 24 | 25 | $loader = new Loader\XmlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 26 | $loader->load('services.xml'); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Address.php: -------------------------------------------------------------------------------- 1 | name; 17 | } 18 | 19 | public function getCompany() 20 | { 21 | return $this->company; 22 | } 23 | 24 | public function getStreet() 25 | { 26 | return $this->street; 27 | } 28 | 29 | public function getPostalcode() 30 | { 31 | return $this->postalcode; 32 | } 33 | 34 | public function getCity() 35 | { 36 | return $this->city; 37 | } 38 | 39 | public function getCountry() 40 | { 41 | return $this->country; 42 | } 43 | 44 | public function setName($name) 45 | { 46 | $this->name = $name; 47 | 48 | return $this; 49 | } 50 | 51 | public function setCompany($company) 52 | { 53 | $this->company = $company; 54 | 55 | return $this; 56 | } 57 | 58 | public function setStreet($street) 59 | { 60 | $this->street = $street; 61 | 62 | return $this; 63 | } 64 | 65 | public function setPostalcode($postalcode) 66 | { 67 | $this->postalcode = $postalcode; 68 | 69 | return $this; 70 | } 71 | 72 | public function setCity($city) 73 | { 74 | $this->city = $city; 75 | 76 | return $this; 77 | } 78 | 79 | public function setCountry($country) 80 | { 81 | $this->country = $country; 82 | 83 | return $this; 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Addresses.php: -------------------------------------------------------------------------------- 1 | addresses = new ArrayCollection(); 14 | } 15 | 16 | public function getAddresses() 17 | { 18 | return $this->addresses; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Advanced/FormWithSeveralCollections/City.php: -------------------------------------------------------------------------------- 1 | name; 15 | } 16 | 17 | /** 18 | * @param string $name 19 | */ 20 | public function setName($name) 21 | { 22 | $this->name = $name; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Advanced/FormWithSeveralCollections/Hobby.php: -------------------------------------------------------------------------------- 1 | type; 15 | } 16 | 17 | /** 18 | * @param string $type 19 | */ 20 | public function setType($type) 21 | { 22 | $this->type = $type; 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Advanced/FormWithSeveralCollections/Travel.php: -------------------------------------------------------------------------------- 1 | cities = new ArrayCollection(); 17 | $this->hobbies = new ArrayCollection(); 18 | } 19 | 20 | /** 21 | * @return mixed 22 | */ 23 | public function getContact() 24 | { 25 | return $this->contact; 26 | } 27 | 28 | /** 29 | * @param mixed $contact 30 | */ 31 | public function setContact($contact) 32 | { 33 | $this->contact = $contact; 34 | } 35 | 36 | /** 37 | * @return ArrayCollection 38 | */ 39 | public function getCities() 40 | { 41 | return $this->cities; 42 | } 43 | 44 | /** 45 | * @return ArrayCollection 46 | */ 47 | public function getHobbies() 48 | { 49 | return $this->hobbies; 50 | } 51 | 52 | /** 53 | * @return string 54 | */ 55 | public function getComments() 56 | { 57 | return $this->comments; 58 | } 59 | 60 | /** 61 | * @param string $comments 62 | */ 63 | public function setComments($comments) 64 | { 65 | $this->comments = $comments; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Basic/InATable/Discount.php: -------------------------------------------------------------------------------- 1 | quantityFrom; 14 | } 15 | 16 | public function setQuantityFrom($quantityFrom) 17 | { 18 | $this->quantityFrom = $quantityFrom; 19 | 20 | return $this; 21 | } 22 | 23 | public function getQuantityTo() 24 | { 25 | return $this->quantityTo; 26 | } 27 | 28 | public function setQuantityTo($quantityTo) 29 | { 30 | $this->quantityTo = $quantityTo; 31 | 32 | return $this; 33 | } 34 | 35 | public function getDiscount() 36 | { 37 | return $this->discount; 38 | } 39 | 40 | public function setDiscount($discount) 41 | { 42 | $this->discount = $discount; 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Basic/InATable/DiscountCollection.php: -------------------------------------------------------------------------------- 1 | discounts = new ArrayCollection(); 15 | } 16 | 17 | public function getProductName() 18 | { 19 | return $this->productName; 20 | } 21 | 22 | public function setProductName($productName) 23 | { 24 | $this->productName = $productName; 25 | 26 | return $this; 27 | } 28 | 29 | public function getDiscounts() 30 | { 31 | return $this->discounts; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Basic/PositionField/Action.php: -------------------------------------------------------------------------------- 1 | id; 14 | } 15 | 16 | public function setId($id) 17 | { 18 | $this->id = $id; 19 | } 20 | 21 | public function getName() 22 | { 23 | return $this->name; 24 | } 25 | 26 | public function setName($name) 27 | { 28 | $this->name = $name; 29 | 30 | return $this; 31 | } 32 | 33 | public function getPosition() 34 | { 35 | return $this->position; 36 | } 37 | 38 | public function setPosition($position) 39 | { 40 | $this->position = $position; 41 | 42 | return $this; 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Basic/PositionField/Actions.php: -------------------------------------------------------------------------------- 1 | actions = new ArrayCollection(); 14 | } 15 | 16 | public function getActions() 17 | { 18 | return $this->actions; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Fancy.php: -------------------------------------------------------------------------------- 1 | a; 14 | } 15 | 16 | public function getB() 17 | { 18 | return $this->b; 19 | } 20 | 21 | public function getC() 22 | { 23 | return $this->c; 24 | } 25 | 26 | public function setA($a) 27 | { 28 | $this->a = $a; 29 | 30 | return $this; 31 | } 32 | 33 | public function setB($b) 34 | { 35 | $this->b = $b; 36 | 37 | return $this; 38 | } 39 | 40 | public function setC($c) 41 | { 42 | $this->c = $c; 43 | 44 | return $this; 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/FancyCollection.php: -------------------------------------------------------------------------------- 1 | fancyCollection = new ArrayCollection(); 14 | } 15 | 16 | public function getFancyCollection() 17 | { 18 | return $this->fancyCollection; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Home/Fruit.php: -------------------------------------------------------------------------------- 1 | name = $name; 12 | } 13 | 14 | public function setName($name) 15 | { 16 | $this->name = $name; 17 | 18 | return $this; 19 | } 20 | 21 | public function getName() 22 | { 23 | return $this->name; 24 | } 25 | 26 | public function __toString() 27 | { 28 | return $this->name; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/MyArray.php: -------------------------------------------------------------------------------- 1 | elements = new ArrayCollection(); 45 | } 46 | 47 | public function getId() 48 | { 49 | return $this->id; 50 | } 51 | 52 | public function getName() 53 | { 54 | return $this->name; 55 | } 56 | 57 | public function setName($name) 58 | { 59 | $this->name = $name; 60 | 61 | return $this; 62 | } 63 | 64 | public function getElements() 65 | { 66 | return $this->elements; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/MyElement.php: -------------------------------------------------------------------------------- 1 | id = $id; 42 | 43 | return $this; 44 | } 45 | 46 | public function getId() 47 | { 48 | return $this->id; 49 | } 50 | 51 | public function setArray(MyArray $array) 52 | { 53 | $this->array = $array; 54 | 55 | return $this; 56 | } 57 | 58 | public function getArray() 59 | { 60 | return $this->array; 61 | } 62 | 63 | public function setValue($value) 64 | { 65 | $this->value = $value; 66 | 67 | return $this; 68 | } 69 | 70 | public function getValue() 71 | { 72 | return $this->value; 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Task.php: -------------------------------------------------------------------------------- 1 | task; 13 | } 14 | 15 | public function setTask($task) 16 | { 17 | $this->task = $task; 18 | } 19 | 20 | public function getDueDate() 21 | { 22 | return $this->dueDate; 23 | } 24 | 25 | public function setDueDate(\DateTime $dueDate = null) 26 | { 27 | $this->dueDate = $dueDate; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Tasks.php: -------------------------------------------------------------------------------- 1 | tasks = new ArrayCollection(); 14 | } 15 | 16 | public function getTasks() 17 | { 18 | return $this->tasks; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Entity/Value.php: -------------------------------------------------------------------------------- 1 | value = $value; 12 | } 13 | 14 | public function setValue($value) 15 | { 16 | $this->value = $value; 17 | 18 | return $this; 19 | } 20 | 21 | public function getValue() 22 | { 23 | return $this->value; 24 | } 25 | 26 | public function __toString() 27 | { 28 | return $this->value; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/AddressType.php: -------------------------------------------------------------------------------- 1 | add('name'); 14 | $builder->add('company'); 15 | $builder->add('street'); 16 | $builder->add('postalcode'); 17 | $builder->add('city'); 18 | $builder->add('country'); 19 | } 20 | 21 | public function configureOptions(OptionsResolver $resolver) 22 | { 23 | $resolver->setDefaults([ 24 | 'data_class' => 'Fuz\AppBundle\Entity\Address', 25 | ]); 26 | } 27 | 28 | public function getBlockPrefix() 29 | { 30 | return 'AddressType'; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/AddressesType.php: -------------------------------------------------------------------------------- 1 | add('addresses', CollectionType::class, [ 16 | 'label' => 'Address', 17 | 'entry_type' => AddressType::class, 18 | 'allow_add' => true, 19 | 'allow_delete' => true, 20 | 'prototype' => true, 21 | 'required' => false, 22 | 'by_reference' => true, 23 | 'delete_empty' => true, 24 | 'attr' => [ 25 | 'class' => 'collection', 26 | ], 27 | ]); 28 | 29 | $builder->add('save', SubmitType::class, [ 30 | 'label' => 'See my addresses', 31 | ]); 32 | } 33 | 34 | public function configureOptions(OptionsResolver $resolver) 35 | { 36 | $resolver->setDefaults([ 37 | 'data_class' => 'Fuz\AppBundle\Entity\Addresses', 38 | ]); 39 | } 40 | 41 | public function getBlockPrefix() 42 | { 43 | return 'AddressesType'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Advanced/FormWithSeveralCollections/CityType.php: -------------------------------------------------------------------------------- 1 | add('name', TextType::class, [ 16 | 'label' => false, 17 | ]); 18 | } 19 | 20 | public function configureOptions(OptionsResolver $resolver) 21 | { 22 | $resolver->setDefaults([ 23 | 'data_class' => City::class, 24 | ]); 25 | } 26 | 27 | public function getBlockPrefix() 28 | { 29 | return 'city'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Advanced/FormWithSeveralCollections/HobbyType.php: -------------------------------------------------------------------------------- 1 | add('type', TextType::class, [ 16 | 'label' => false, 17 | ]); 18 | } 19 | 20 | public function configureOptions(OptionsResolver $resolver) 21 | { 22 | $resolver->setDefaults([ 23 | 'data_class' => Hobby::class, 24 | ]); 25 | } 26 | 27 | public function getBlockPrefix() 28 | { 29 | return 'hobby'; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Basic/InATable/DiscountCollectionType.php: -------------------------------------------------------------------------------- 1 | add('productName', TextType::class, [ 18 | 'label' => 'Product name', 19 | ]) 20 | ->add('discounts', CollectionType::class, [ 21 | 'label' => 'Manage product discounts based on quantity bought.', 22 | 'entry_type' => DiscountType::class, 23 | 'entry_options' => [ 24 | 'attr' => [ 25 | 'class' => 'item', // we want to use 'tr.item' as collection elements' selector 26 | ], 27 | ], 28 | 'allow_add' => true, 29 | 'allow_delete' => true, 30 | 'prototype' => true, 31 | 'required' => false, 32 | 'by_reference' => true, 33 | 'delete_empty' => true, 34 | 'attr' => [ 35 | 'class' => 'table discount-collection', 36 | ], 37 | 38 | ]) 39 | ->add('save', SubmitType::class, [ 40 | 'label' => 'Save', 41 | ]) 42 | ; 43 | } 44 | 45 | public function configureOptions(OptionsResolver $resolver) 46 | { 47 | $resolver->setDefaults([ 48 | 'data_class' => 'Fuz\AppBundle\Entity\Basic\InATable\DiscountCollection', 49 | ]); 50 | } 51 | 52 | public function getBlockPrefix() 53 | { 54 | return 'DiscountCollectionType'; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Basic/InATable/DiscountType.php: -------------------------------------------------------------------------------- 1 | add('quantityFrom', IntegerType::class, [ 17 | 'label' => false, 18 | ]) 19 | ->add('quantityTo', IntegerType::class, [ 20 | 'label' => false, 21 | ]) 22 | ->add('discount', PercentType::class, [ 23 | 'label' => false, 24 | 'type' => 'integer', 25 | ]) 26 | ; 27 | } 28 | 29 | public function configureOptions(OptionsResolver $resolver) 30 | { 31 | $resolver->setDefaults([ 32 | 'data_class' => 'Fuz\AppBundle\Entity\Basic\InATable\Discount', 33 | ]); 34 | } 35 | 36 | public function getBlockPrefix() 37 | { 38 | return 'DiscountType'; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Basic/PositionField/ActionType.php: -------------------------------------------------------------------------------- 1 | add('id', TextType::class, [ 17 | 'attr' => [ 18 | 'readonly' => true, 19 | 'autocomplete' => 'off', 20 | ], 21 | ]); 22 | 23 | $builder->add('name', TextType::class, [ 24 | 'attr' => [ 25 | 'autocomplete' => 'off', 26 | ] 27 | ]); 28 | 29 | // position would usually be stored in a hidden type, but here we want 30 | // you to see the result explicitely 31 | $builder->add('position', TextType::class, [ 32 | 'attr' => [ 33 | 'readonly' => true, 34 | 'class' => 'my-position', // selector is the one used on the js side 35 | 'autocomplete' => 'off', 36 | ], 37 | ]); 38 | } 39 | 40 | public function configureOptions(OptionsResolver $resolver) 41 | { 42 | $resolver->setDefaults([ 43 | 'data_class' => 'Fuz\AppBundle\Entity\Basic\PositionField\Action', 44 | ]); 45 | } 46 | 47 | public function getBlockPrefix() 48 | { 49 | return 'ActionType'; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Basic/PositionField/ActionsType.php: -------------------------------------------------------------------------------- 1 | add('actions', CollectionType::class, [ 16 | 'label' => 'Actions to do after waking up (executed in the given order)', 17 | 'entry_type' => ActionType::class, 18 | 'allow_add' => true, 19 | 'allow_delete' => true, 20 | 'prototype' => true, 21 | 'required' => false, 22 | 'by_reference' => true, 23 | 'delete_empty' => true, 24 | 'attr' => [ 25 | 'class' => 'actions-collection', 26 | ], 27 | ]); 28 | 29 | $builder->add('save', SubmitType::class, [ 30 | 'label' => 'See actions', 31 | ]); 32 | } 33 | 34 | public function configureOptions(OptionsResolver $resolver) 35 | { 36 | $resolver->setDefaults([ 37 | 'data_class' => 'Fuz\AppBundle\Entity\Basic\PositionField\Actions', 38 | ]); 39 | } 40 | 41 | public function getBlockPrefix() 42 | { 43 | return 'ActionsType'; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/FancyCollectionType.php: -------------------------------------------------------------------------------- 1 | add('fancyCollection', Type\CollectionType::class, [ 16 | 'entry_type' => FancyType::class, 17 | 'label' => 'Add, move, remove values and press Submit.', 18 | 'allow_add' => true, 19 | 'allow_delete' => true, 20 | 'prototype' => true, 21 | 'required' => false, 22 | 'attr' => [ 23 | 'class' => 'collection', 24 | ], 25 | ]); 26 | 27 | $builder->add('save', SubmitType::class, [ 28 | 'label' => 'See my data', 29 | ]); 30 | } 31 | 32 | public function configureOptions(OptionsResolver $resolver) 33 | { 34 | $resolver->setDefaults([ 35 | 'data_class' => 'Fuz\AppBundle\Entity\FancyCollection', 36 | ]); 37 | } 38 | 39 | public function getBlockPrefix() 40 | { 41 | return 'FancyCollectionType'; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/FancyType.php: -------------------------------------------------------------------------------- 1 | add('a'); 14 | $builder->add('b'); 15 | $builder->add('c'); 16 | } 17 | 18 | public function configureOptions(OptionsResolver $resolver) 19 | { 20 | $resolver->setDefaults([ 21 | 'data_class' => 'Fuz\AppBundle\Entity\Fancy', 22 | ]); 23 | } 24 | 25 | public function getBlockPrefix() 26 | { 27 | return 'FancyType'; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/Home/FruitType.php: -------------------------------------------------------------------------------- 1 | add('name', TextType::class, [ 16 | 'required' => true, 17 | 'label' => 'Fruit name', 18 | ]) 19 | ; 20 | } 21 | 22 | public function configureOptions(OptionsResolver $resolver) 23 | { 24 | $resolver->setDefaults([ 25 | 'data_class' => 'Fuz\AppBundle\Entity\Home\Fruit', 26 | ]); 27 | } 28 | 29 | public function getBlockPrefix() 30 | { 31 | return 'FruitType'; 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/MyArrayType.php: -------------------------------------------------------------------------------- 1 | add('name', TextType::class, [ 17 | 'label' => 'Array name:', 18 | ]); 19 | 20 | $builder->add('elements', CollectionType::class, [ 21 | 'label' => 'Add an element...', 22 | 'entry_type' => MyElementType::class, 23 | 'allow_add' => true, 24 | 'allow_delete' => true, 25 | 'prototype' => true, 26 | 'required' => false, 27 | 'by_reference' => true, 28 | 'delete_empty' => true, 29 | 'attr' => [ 30 | 'class' => 'doctrine-sample', 31 | ], 32 | ]); 33 | 34 | $builder->add('save', SubmitType::class, [ 35 | 'label' => 'Save this array', 36 | ]); 37 | } 38 | 39 | public function configureOptions(OptionsResolver $resolver) 40 | { 41 | $resolver->setDefaults([ 42 | 'data_class' => 'Fuz\AppBundle\Entity\MyArray', 43 | ]); 44 | } 45 | 46 | public function getBlockPrefix() 47 | { 48 | return 'my_array'; 49 | } 50 | } 51 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/MyElementType.php: -------------------------------------------------------------------------------- 1 | add('value', TextType::class, [ 15 | 'required' => false, 16 | ]); 17 | } 18 | 19 | public function configureOptions(OptionsResolver $resolver) 20 | { 21 | $resolver->setDefaults([ 22 | 'data_class' => 'Fuz\AppBundle\Entity\MyElement', 23 | ]); 24 | } 25 | 26 | public function getBlockPrefix() 27 | { 28 | return 'my_element'; 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/TaskType.php: -------------------------------------------------------------------------------- 1 | getBlockPrefix()); 15 | 16 | $builder 17 | ->add('task', 'Symfony\Component\Form\Extension\Core\Type\TextType') 18 | ->add('dueDate', 'Symfony\Component\Form\Extension\Core\Type\DateType') 19 | ; 20 | } 21 | 22 | public function configureOptions(OptionsResolver $resolver) 23 | { 24 | $resolver->setDefaults([ 25 | 'data_class' => 'Fuz\AppBundle\Entity\Task', 26 | ]); 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/TasksType.php: -------------------------------------------------------------------------------- 1 | add('tasks', CollectionType::class, [ 16 | 'label' => 'Tasks', 17 | 'entry_type' => TaskType::class, 18 | 'allow_add' => true, 19 | 'allow_delete' => true, 20 | 'prototype' => true, 21 | 'required' => false, 22 | 'by_reference' => true, 23 | 'delete_empty' => true, 24 | ]); 25 | 26 | $builder->add('save', SubmitType::class, [ 27 | 'label' => 'See my tasks', 28 | ]); 29 | } 30 | 31 | public function configureOptions(OptionsResolver $resolver) 32 | { 33 | $resolver->setDefaults([ 34 | 'data_class' => 'Fuz\AppBundle\Entity\Tasks', 35 | ]); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Form/ValueType.php: -------------------------------------------------------------------------------- 1 | add('value', TextType::class, 16 | [ 17 | 'required' => true, 18 | 'label' => 'Value', 19 | ]) 20 | ; 21 | } 22 | 23 | public function configureOptions(OptionsResolver $resolver) 24 | { 25 | $resolver->setDefaults([ 26 | 'data_class' => 'Fuz\AppBundle\Entity\Value', 27 | ]); 28 | } 29 | 30 | public function getBlockPrefix() 31 | { 32 | return 'ValueType'; 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/FuzAppBundle.php: -------------------------------------------------------------------------------- 1 | setName($name); 18 | try { 19 | $this->_em->persist($data); 20 | $this->_em->flush(); 21 | } catch (UniqueConstraintViolationException $e) { 22 | return null; 23 | } 24 | 25 | return $data; 26 | } 27 | 28 | public function save(MyArray $data) 29 | { 30 | foreach ($data->getElements() as $element) { 31 | $element->setArray($data); 32 | } 33 | try { 34 | $this->_em->persist($data); 35 | $this->_em->flush(); 36 | } catch (UniqueConstraintViolationException $e) { 37 | return null; 38 | } 39 | 40 | return $data; 41 | } 42 | 43 | public function getArrayNames() 44 | { 45 | $arrays = $this 46 | ->_em 47 | ->createQuery(" 48 | SELECT arr.name 49 | FROM Fuz\AppBundle\Entity\MyArray arr 50 | ") 51 | ->execute(); 52 | $names = []; 53 | foreach ($arrays as $array) { 54 | $names[] = $array['name']; 55 | } 56 | 57 | return $names; 58 | } 59 | 60 | public function delete(MyArray $data) 61 | { 62 | foreach ($data->getElements() as $element) { 63 | $this->_em->remove($element); 64 | } 65 | $this->_em->remove($data); 66 | $this->_em->flush(); 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/config/services.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/translations/messages.en.xlf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/translations/messages.fr.xlf: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/FormWithSeveralCollections/form-theme.html.twig: -------------------------------------------------------------------------------- 1 | {% block city_widget %} 2 | 3 |
4 |
5 | {{ form_widget(form) }} 6 |
7 |
8 | {# Note that "city" on classes below are the same as on "prefix" option #} 9 | 10 | 11 |
12 |
13 | 14 | {% endblock %} 15 | 16 | {% block hobby_widget %} 17 | 18 |
19 |
20 | {{ form_widget(form) }} 21 |
22 |
23 | {# Note that "hobby" on classes below are the same as on "prefix" option #} 24 | 25 | 26 |
27 |
28 | 29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/addresses-theme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block AddressesType_label %}{% endblock %} 3 | {% block AddressesType_errors %}{% endblock %} 4 | 5 | {% block AddressType_label %}{% endblock %} 6 | {% block AddressType_errors %}{% endblock %} 7 | 8 | {% block AddressType_row %} 9 |
10 | {{ form_label(form) }} 11 | {{ form_errors(form) }} 12 | {{ form_widget(form) }} 13 |
14 | {% endblock %} 15 | 16 | {% block AddressType_widget %} 17 | {{ form_widget(form) }} 18 |
19 |

20 | < 21 | - 22 | + 23 | > 24 |

25 | {% endblock %} 26 | 27 | {% block AddressesType_widget %} 28 | {{ form_widget(form.addresses) }} 29 | {% endblock %} 30 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/advanced-theme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block ValueType_label %}{% endblock %} 3 | {% block ValueType_errors %}{% endblock %} 4 | 5 | {% block ValueType_widget %} 6 | 7 |
8 |
9 | {{ form_widget(form.value) }} 10 |
11 |
12 | Up 13 | Down 14 |
15 |
16 | Remove 17 | Add 18 |
19 |
20 | Duplicate 21 |
22 |
23 | 24 | {% endblock %} 25 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/customFormTheme.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Advanced usage: custom form theme{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

14 | A button is no more than anything containing collection-up, collection-down, collection-add 15 | or collection-remove classes. 16 |

17 | 18 |

19 | So you can customize buttons by creating a form theme for the form type that will be used inside the collection. 20 |

21 | 22 |

23 | There is only 1 limit: if you're customizing the native collection theme, you should put collection elements in a div one level 24 | deeper than the collection's root and no more. This is because the plugin uses $('#collection').find('> div'); to find collection's 25 | elements. If you feel that the > div selector should be customizable in a plugin option, please open an issue on Github. 26 |

27 | 28 | {% 29 | form_theme form 30 | 'jquery.collection.html.twig' 31 | 'FuzAppBundle:Advanced:advanced-theme.html.twig' 32 | %} 33 | 34 | {{ form(form) }} 35 | 36 | {% for value in data.values %} 37 |

Value : {{ value }}

38 | {% endfor %} 39 | 40 | {{ 41 | tabs([ 42 | 'Base/BaseController.php', 43 | 'Controller/AdvancedController.php', 44 | 'Resources/views/Advanced/customFormTheme.html.twig', 45 | 'Resources/views/Advanced/advanced-theme.html.twig', 46 | ]) 47 | }} 48 | 49 | {% endblock %} 50 | 51 | {% block script %} 52 | 53 | 58 | 59 | {% endblock %} 60 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/doctrine-theme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block my_element_label %}{% endblock %} 3 | {% block my_element_errors %}{% endblock %} 4 | 5 | {% block my_element_widget %} 6 | 7 |
8 |
9 | {{ form_widget(form.value) }} 10 |
11 |
12 | Up 13 | Down 14 |
15 |
16 | Remove 17 | Add 18 |
19 |
20 | Duplicate 21 |
22 |
23 | 24 | {% endblock %} 25 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/fancy-theme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block FancyType_row %} 3 | 4 |
5 |
6 |
{{ form_label(form.a) }}
7 |
{{ form_widget(form.a) }}
8 |
9 |
10 |
{{ form_label(form.b) }}
11 |
{{ form_widget(form.b) }}
12 |
13 |
14 |
{{ form_label(form.c) }}
15 |
{{ form_widget(form.c) }}
16 |
17 | 18 |
19 | 20 | 21 |
22 |
23 | 24 | 25 |
26 |
27 | 28 |
29 |
30 | 31 | {% endblock %} 32 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/fancyFormTheme.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Advanced usage: custom theme with several aligned fields{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

14 | An other example of theming a collection, where fields are aligned and labels are 15 | disposed above each widget. 16 |

17 | 18 |
19 | {% 20 | form_theme form 21 | 'jquery.collection.html.twig' 22 | 'FuzAppBundle:Advanced:fancy-theme.html.twig' 23 | %} 24 | {{ form(form) }} 25 |
26 | 27 | {% for row in data.fancyCollection %} 28 |

29 | a = {{ row.a }}, b = {{ row.b }}, c = {{ row.c }} 30 |

31 | {% endfor %} 32 | 33 | {{ 34 | tabs([ 35 | 'Base/BaseController.php', 36 | 'Controller/AdvancedController.php', 37 | 'Resources/views/Advanced/fancy-theme.html.twig', 38 | 'Resources/views/Advanced/fancyFormTheme.html.twig', 39 | 'Entity/FancyCollection.php', 40 | 'Entity/Fancy.php', 41 | 'Form/FancyCollectionType.php', 42 | 'Form/FancyType.php', 43 | ]) 44 | }} 45 | 46 | {% endblock %} 47 | 48 | {% block script %} 49 | 50 | 58 | 59 | {% endblock %} 60 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/formHavingSeveralFields.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Advanced usage: custom theme and several fields{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

14 | An example that shows how works theming on a form with more than one field. 15 |

16 | 17 |
18 | {% 19 | form_theme form 20 | 'jquery.collection.html.twig' 21 | 'FuzAppBundle:Advanced:addresses-theme.html.twig' 22 | %} 23 | {{ form(form) }} 24 |
25 | 26 | {% for address in data.addresses %} 27 |

28 | {{ address.name }} at {{ address.company }}, {{ address.street }}, {{ address.postalcode }} {{ address.city }}, {{ address.country }} 29 |

30 | {% endfor %} 31 | 32 | {{ 33 | tabs([ 34 | 'Base/BaseController.php', 35 | 'Controller/AdvancedController.php', 36 | 'Resources/views/Advanced/addresses-theme.html.twig', 37 | 'Resources/views/Advanced/formHavingSeveralFields.html.twig', 38 | 'Entity/Addresses.php', 39 | 'Entity/Address.php', 40 | 'Form/AddressesType.php', 41 | 'Form/AddressType.php', 42 | ]) 43 | }} 44 | 45 | {% endblock %} 46 | 47 | {% block script %} 48 | 49 | 56 | 57 | {% endblock %} 58 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Advanced/mvcCompliance.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Advanced usage: MVC compliance{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

14 | In the Basic Usage example, we defined the collection's selector in the form type, but that's not a 15 | good practice, as a selector should take part of the view. 16 |

17 | 18 |

19 | You can reference your form collection using any container, such as a {{ '

'|e }}, and setting 20 | data-collection="{% verbatim %}{{ form.collectionField.vars.id }}{% endverbatim %}". 21 |

22 | 23 | {% form_theme form 'jquery.collection.html.twig' %} 24 | {{ form(form) }} 25 | 26 |
27 | 28 | {% for value in data.values %} 29 |

Value : {{ value }}

30 | {% endfor %} 31 | 32 |
33 | 34 |

Code used:

35 |
{{ block('script') | e }}
36 | 37 | {{ 38 | tabs([ 39 | 'Base/BaseController.php', 40 | 'Controller/AdvancedController.php', 41 | 'Resources/views/Advanced/mvcCompliance.html.twig', 42 | ]) 43 | }} 44 | 45 | {% endblock %} 46 | 47 | {% block script %} 48 | 49 | 50 |
51 | 52 | 55 | 56 | {% endblock %} 57 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Basic/PositionField/formTheme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {# remove any label above each element #} 3 | {% block ActionType_label %} 4 | {% endblock %} 5 | 6 | {# better disposition of each elements #} 7 | {% block ActionType_widget %} 8 | 9 |
10 |
11 | {{ form_row(form.id) }} 12 |
13 |
14 | {{ form_row(form.name) }} 15 |
16 |
17 | {{ form_row(form.position) }} 18 |
19 |
20 |
21 | 22 | 23 | 24 | 25 | 26 |
27 |
28 |
29 | 30 | {% endblock %} 31 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Basic/SimpleCollection/simpleCollection.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Basic usage{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

Basic usage

12 | 13 |

This is a collection of simple text fields using the plugin with all default options.

14 | 15 | {% form_theme form 'jquery.collection.html.twig' %} 16 | {{ form(form) }} 17 | 18 |
19 | 20 | {% for value in data.values %} 21 |

Value : {{ value }}

22 | {% endfor %} 23 | 24 |
25 | 26 |

Code used to initialize the collection:

27 |
{{ block('script') | e }}
28 | 29 |

Full Symfony code:

30 | {{ 31 | tabs([ 32 | 'Controller/Basic/SimpleCollectionController.php', 33 | 'Resources/views/Basic/SimpleCollection/simpleCollection.html.twig', 34 | ]) 35 | }} 36 | 37 | {% endblock %} 38 | 39 | {% block script %} 40 | 41 | 44 | 45 | {% endblock %} 46 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Home/Home/formThemeNoButtons.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block FruitType_label %}{% endblock %} 3 | 4 | {% block FruitType_widget %} 5 | 6 | {{ form_widget(form.name) }} 7 | 8 | {% endblock %} 9 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Home/Home/formThemeWithButtons.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block FruitType_label %}{% endblock %} 3 | 4 | {% block FruitType_widget %} 5 | 6 |
7 |
8 | {{ form_widget(form.name) }} 9 |
10 |
11 | 12 | 13 |
14 |
15 | 16 | 17 |
18 |
19 | 20 |
21 |
22 | 23 | {% endblock %} 24 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Options/customButtons.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}JavaScript options : customize buttons' layout{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

Use up, down, add and remove options to customize your buttons.

14 | 15 |

Note that you can still do more advanced customization (of buttons' position) using form themes.

16 | 17 | {% form_theme form 'jquery.collection.html.twig' %} 18 | {{ form(form) }} 19 | 20 |
21 | 22 | {% for value in formData.values %} 23 |

Value : {{ value }}

24 | {% endfor %} 25 | 26 |
27 | 28 |

Code used:

29 |
{{ block('script') | e }}
30 | 31 | {{ 32 | tabs([ 33 | 'Controller/OptionsController.php', 34 | 'Base/BaseController.php', 35 | 'Resources/views/Options/customButtons.html.twig', 36 | ]) 37 | }} 38 | 39 | {% endblock %} 40 | 41 | {% block script %} 42 | 43 | 53 | 54 | {% endblock %} 55 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Options/fadeInFadeOut.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}JavaScript options : fadeIn / fadeOut animations{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

Use fade_in and fade_out options to disable fade animation when adding / removing elements of the collection.

14 | 15 |

Both options are enabled (true) by default.

16 | 17 |

Test it live:

18 | 19 |

- Fade In when adding an element to the collection:

20 | 21 |

- Fade Out when removing an element from the collection:

22 | 23 | {% form_theme form 'jquery.collection.html.twig' %} 24 | {{ form(form) }} 25 | 26 |
27 | 28 | {% for value in formData.values %} 29 |

Value : {{ value }}

30 | {% endfor %} 31 | 32 |
33 | 34 |

Code used:

35 |
{{ block('script') | e }}
36 | 37 | {{ 38 | tabs([ 39 | 'Base/BaseController.php', 40 | 'Controller/OptionsController.php', 41 | 'Resources/views/Options/fadeInFadeOut.html.twig', 42 | ]) 43 | }} 44 | 45 | {% endblock %} 46 | 47 | {% block script %} 48 | 49 | 63 | 64 | {% endblock %} 65 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Options/givenMinimumElements.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}JavaScript options : Initialize your collection with a given minimum number of elements{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

Use init_with_n_elements option to ensure that your collection will be initialized with the given number of arguments. 14 | 15 | {% form_theme form 'jquery.collection.html.twig' %} 16 | {{ form(form) }} 17 | 18 |


19 | 20 | {% for value in formData.values %} 21 |

Value : {{ value }}

22 | {% endfor %} 23 | 24 |
25 | 26 |

Code used:

27 |
{{ block('script') | e }}
28 | 29 | {{ 30 | tabs([ 31 | 'Base/BaseController.php', 32 | 'Controller/OptionsController.php', 33 | 'Resources/views/Options/givenMinimumElements.html.twig', 34 | ]) 35 | }} 36 | 37 | {% endblock %} 38 | 39 | {% block script %} 40 | 41 | 52 | 53 | {% endblock %} 54 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Options/hideMoveUpDown.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}JavaScript options : hide Up and Down buttons on useless elements{% endblock %} 8 | 9 | {% block body %} 10 | 11 |

{{ block('title') }}

12 | 13 |

Use hide_useless_buttons option to display or not the up button on the first item, and the down button on the last one.

14 | 15 |

This can be useful if you want to style useless buttons by yourself, instead of display:none.

16 | 17 |

Test it live:

18 | 19 | {% form_theme form 'jquery.collection.html.twig' %} 20 | {{ form(form) }} 21 | 22 |
23 | 24 | {% for value in formData.values %} 25 |

Value : {{ value }}

26 | {% endfor %} 27 | 28 |
29 | 30 |

Code used:

31 |
{{ block('script') | e }}
32 | 33 | {{ 34 | tabs([ 35 | 'Base/BaseController.php', 36 | 'Controller/OptionsController.php', 37 | 'Resources/views/Options/hideMoveUpDown.html.twig', 38 | 'Resources/views/Options/options-theme.html.twig', 39 | ]) 40 | }} 41 | 42 | {% endblock %} 43 | 44 | {% block script %} 45 | 46 | 65 | 66 | {% endblock %} 67 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Options/options-theme.html.twig: -------------------------------------------------------------------------------- 1 | 2 | {% block ValueType_label %}{% endblock %} 3 | {% block ValueType_errors %}{% endblock %} 4 | 5 | {% block ValueType_widget %} 6 | 7 |
8 |
9 | {{ form_widget(form.value) }} 10 |
11 |
12 | 13 | 14 |
15 |
16 | 17 | 18 |
19 |
20 | 21 |
22 |
23 | 24 | {% endblock %} 25 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/Troubleshoot/customJqueryVersion.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzAppBundle::layout.html.twig' %} 2 | 3 | {% block extra_js %} 4 | 5 | {% endblock %} 6 | 7 | {% block title %}Basic usage{% endblock %} 8 | 9 | {# Including the given jQuery version #} 10 | {% block jquery %}{% if jquery %}{{ jquery }}{% else %}{{ parent() }}{% endif %}{% endblock %} 11 | 12 | {% block body %} 13 | 14 |

Try this plugin with another jQuery version

15 | 16 |

Enter a jQuery URL in the field below to include it instead of the current version.

17 |

You can find jQuery core urls at https://code.jquery.com/jquery/

18 | 19 | {% form_theme form 'jquery.collection.html.twig' %} 20 | {{ form(form) }} 21 | 22 |
23 | 24 | {% for value in data.values %} 25 |

Value : {{ value }}

26 | {% endfor %} 27 | 28 |
29 | 30 |

Code used:

31 |
{{ block('script') | e }}
32 | 33 | {% endblock %} 34 | 35 | {% block script %} 36 | 37 | 40 | 41 | {% endblock %} 42 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/github.html.twig: -------------------------------------------------------------------------------- 1 | {# see Fuz\AppBundle\Twig\Extension\HelperExtension.php #} 2 | 3 | {{ path }} 4 | 5 | 6 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/layout.html.twig: -------------------------------------------------------------------------------- 1 | {% extends 'FuzQuickStartBundle::layout.html.twig' %} 2 | 3 | {% block brand %}Symfony Collection{% endblock %} 4 | {% block title %}{% endblock %} 5 | 6 | {% block login %}{% endblock %} 7 | {% block translations %}{% endblock %} 8 | 9 | {% block menu %} 10 | {{ knp_menu_render('FuzAppBundle:Builder:mainMenu') }} 11 | {% endblock %} 12 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Resources/views/tabs.html.twig: -------------------------------------------------------------------------------- 1 |
2 | 3 | 8 | 9 |
10 | {% for file, contents in tabs %} 11 |
12 |
File: {{ github(file) }}
13 |
{{ contents }}
14 |
File: {{ github(file) }}
15 |
16 | {% endfor %} 17 |
18 | 19 |
20 | -------------------------------------------------------------------------------- /src/Fuz/AppBundle/Twig/Extension/HelperExtension.php: -------------------------------------------------------------------------------- 1 | twig = $twig; 12 | } 13 | 14 | public function getFunctions() 15 | { 16 | return [ 17 | new \Twig_SimpleFunction('github', [$this, 'github'], ['is_safe' => ['html']]), 18 | new \Twig_SimpleFunction('tabs', [$this, 'tabs'], ['is_safe' => ['html']]), 19 | new \Twig_SimpleFunction('basename', 'basename'), 20 | ]; 21 | } 22 | 23 | public function getFilters() 24 | { 25 | return [ 26 | new \Twig_SimpleFilter('md5', 'md5', ['is_safe' => ['html']]), 27 | ]; 28 | } 29 | 30 | public function github($path) 31 | { 32 | return $this->twig->render('FuzAppBundle::github.html.twig', [ 33 | 'path' => $path, 34 | ]); 35 | } 36 | 37 | public function tabs($files) 38 | { 39 | $basedir = realpath(__DIR__ . '/../../'); 40 | $tabs = []; 41 | foreach ($this->_getPaths($files) as $file) { 42 | $tabs[$file] = file_get_contents($basedir . '/' . $file); 43 | } 44 | 45 | return $this->twig->render('FuzAppBundle::tabs.html.twig', [ 46 | 'tabs' => $tabs, 47 | ]); 48 | } 49 | 50 | protected function _getPaths($files) 51 | { 52 | $paths = []; 53 | foreach ($files as $file) { 54 | $basedir = realpath(__DIR__ . '/../../'); 55 | $realpath = realpath($basedir . '/' . $file); 56 | 57 | if (!is_file($realpath)) { 58 | throw new \LogicException("File {$file} not found"); 59 | } 60 | 61 | $paths[] = substr($realpath, strlen($basedir) + 1); 62 | } 63 | sort($paths); 64 | 65 | return $paths; 66 | } 67 | 68 | public function getName() 69 | { 70 | return 'helper'; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Base/BaseCommand.php: -------------------------------------------------------------------------------- 1 | container->get($service); 12 | } 13 | 14 | public function getParameter($parameter) 15 | { 16 | return $this->container->getParameter($parameter); 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Base/BaseService.php: -------------------------------------------------------------------------------- 1 | container->get($service); 15 | } 16 | 17 | public function getParameter($parameter) 18 | { 19 | return $this->container->getParameter($parameter); 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Controller/ReloadController.php: -------------------------------------------------------------------------------- 1 | goBack($request); 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/DependencyInjection/Configuration.php: -------------------------------------------------------------------------------- 1 | root('fuz_quick_start'); 22 | 23 | return $treeBuilder; 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/DependencyInjection/FuzQuickStartExtension.php: -------------------------------------------------------------------------------- 1 | processConfiguration($configuration, $configs); 24 | 25 | foreach ($config as $key => $value) { 26 | $container->setParameter($key, $value); 27 | } 28 | 29 | $loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__ . '/../Resources/config')); 30 | $loader->load('services.yml'); 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/EventListener/LastRouteListener.php: -------------------------------------------------------------------------------- 1 | routing = $routing; 18 | } 19 | 20 | public function onKernelRequest(GetResponseEvent $event) 21 | { 22 | $request = $event->getRequest(); 23 | if (!$request->hasPreviousSession()) { 24 | return; 25 | } 26 | 27 | try { 28 | $currentRoute = $this->routing->getCurrentRoute($request); 29 | } catch (ResourceNotFoundException $ex) { 30 | return; 31 | } 32 | if (is_null($currentRoute)) { 33 | return; 34 | } 35 | 36 | $session = $request->getSession(); 37 | $previousRoute = $session->get('current_route', []); 38 | if ($currentRoute == $previousRoute) { 39 | return; 40 | } 41 | 42 | $session->set('previous_route', $previousRoute); 43 | $session->set('current_route', $currentRoute); 44 | } 45 | 46 | public static function getSubscribedEvents() 47 | { 48 | return [ 49 | KernelEvents::REQUEST => [['onKernelRequest', 15]], 50 | ]; 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/EventListener/LocaleListener.php: -------------------------------------------------------------------------------- 1 | defaultLocale = $defaultLocale; 16 | } 17 | 18 | public function onKernelRequest(GetResponseEvent $event) 19 | { 20 | $request = $event->getRequest(); 21 | if (!$request->hasPreviousSession()) { 22 | return; 23 | } 24 | 25 | $locale = $request->attributes->get('_locale'); 26 | if ($locale) { 27 | $request->getSession()->set('_locale', $locale); 28 | } else { 29 | $request->setLocale($request->getSession()->get('_locale', $this->defaultLocale)); 30 | } 31 | } 32 | 33 | public static function getSubscribedEvents() 34 | { 35 | return [ 36 | KernelEvents::REQUEST => [['onKernelRequest', 17]], 37 | ]; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/FuzQuickStartBundle.php: -------------------------------------------------------------------------------- 1 | {{ block('label') }}{% if item.hasChildren and item.getExtra('submenu', false) == false %} {% endif %}{% endblock %} 22 | 23 | {% block dividerElement %}
  • {% endblock %} 24 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Resources/views/layout.html.twig: -------------------------------------------------------------------------------- 1 | {# FuzQuickStartBundle::layout.html.twig #} 2 | 3 | {% extends 'FuzQuickStartBundle::base.html.twig' %} 4 | 5 | {% block menu %} 6 | {{ knp_menu_render('FuzAppBundle:Builder:mainMenu') }} 7 | {% endblock %} 8 | 9 | {% block login %} 10 | {% endblock %} 11 | 12 | {% block translations %} 13 | 23 | {% endblock %} 24 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Services/Routing.php: -------------------------------------------------------------------------------- 1 | router = $router; 19 | } 20 | 21 | public function getCurrentRoute(Request $request) 22 | { 23 | $pathInfo = $request->getPathInfo(); 24 | $hash = sha1(var_export($pathInfo, true)); 25 | if (in_array($hash, $this->cache)) { 26 | return $this->cache[$hash]; 27 | } 28 | 29 | $routeParams = $this->router->match($pathInfo); 30 | $routeName = $routeParams['_route']; 31 | if (substr($routeName, 0, 1) === '_') { 32 | return; 33 | } 34 | unset($routeParams['_route']); 35 | 36 | $data = [ 37 | 'name' => $routeName, 38 | 'params' => $routeParams, 39 | ]; 40 | 41 | $this->cache[$hash] = $data; 42 | 43 | return $data; 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /src/Fuz/QuickStartBundle/Tools/Math.php: -------------------------------------------------------------------------------- 1 | loadClassCache(); 13 | //$kernel = new AppCache($kernel); 14 | 15 | // When using the HttpCache, you need to call the method in your front controller instead of relying on the configuration parameter 16 | //Request::enableHttpMethodParameterOverride(); 17 | $request = Request::createFromGlobals(); 18 | $response = $kernel->handle($request); 19 | $response->send(); 20 | $kernel->terminate($request, $response); 21 | -------------------------------------------------------------------------------- /web/app_dev.php: -------------------------------------------------------------------------------- 1 | loadClassCache(); 29 | $request = Request::createFromGlobals(); 30 | $response = $kernel->handle($request); 31 | $response->send(); 32 | $kernel->terminate($request, $response); 33 | -------------------------------------------------------------------------------- /web/apple-touch-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninsuo/symfony-collection-demo/95c610d487b4f7f783187aecdd09fe4e636155d0/web/apple-touch-icon.png -------------------------------------------------------------------------------- /web/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/ninsuo/symfony-collection-demo/95c610d487b4f7f783187aecdd09fe4e636155d0/web/favicon.ico -------------------------------------------------------------------------------- /web/robots.txt: -------------------------------------------------------------------------------- 1 | # www.robotstxt.org/ 2 | # www.google.com/support/webmasters/bin/answer.py?hl=en&answer=156449 3 | 4 | User-agent: * 5 | --------------------------------------------------------------------------------