From 90e5ac50bdaaae103254580499cdbfac9e55489e Mon Sep 17 00:00:00 2001 From: Ross Masters Date: Mon, 10 Feb 2014 14:25:01 +0000 Subject: [PATCH 01/32] Translate nested keys using square brackets like those with periods Fixes #267 For example, the following inputs will both be translated with the same (Laravel) translation rule: Former::text('address[city]') Former::text('address.city') [ 'validation' => [ 'attributes' => [ 'address' => [ 'city' => 'City' --- src/Former/Helpers.php | 5 +++++ tests/HelpersTest.php | 11 +++++++++++ tests/TestCases/ContainerTestCase.php | 3 +++ 3 files changed, 19 insertions(+) diff --git a/src/Former/Helpers.php b/src/Former/Helpers.php index f521d543..ff87e59c 100644 --- a/src/Former/Helpers.php +++ b/src/Former/Helpers.php @@ -73,6 +73,11 @@ public static function translate($key, $fallback = null) } $translateFrom .= $key; + // Convert a[b[c]] to a.b.c for nested translations [a => [b => 'B!']] + if (strpos($translateFrom, ']') !== false) { + $translateFrom = str_replace(array(']', '['), array('', '.'), $translateFrom); + } + // Search for the key itself if (static::$app['translator']->has($key)) { $translation = static::$app['translator']->get($key); diff --git a/tests/HelpersTest.php b/tests/HelpersTest.php index 84bf1a42..00416741 100644 --- a/tests/HelpersTest.php +++ b/tests/HelpersTest.php @@ -29,4 +29,15 @@ public function testCanDisableTranslationCapitalization() $this->assertEquals('field', Former\Helpers::translate('field')); } + + public function testNestedTranslationFieldNames() + { + $matcher = $this->matchLabel('City', 'address.city'); + $input = $this->former->text('address.city')->__toString(); + $this->assertHTML($matcher, $input); + + $matcher = $this->matchLabel('City', 'address[city]'); + $input = $this->former->text('address[city]')->__toString(); + $this->assertHTML($matcher, $input); + } } diff --git a/tests/TestCases/ContainerTestCase.php b/tests/TestCases/ContainerTestCase.php index 5d42b868..f7bcdac3 100644 --- a/tests/TestCases/ContainerTestCase.php +++ b/tests/TestCases/ContainerTestCase.php @@ -254,8 +254,11 @@ protected function mockTranslator() ->shouldReceive('get')->with('pagination.next')->andReturn('Next') ->shouldReceive('get')->with('pagination')->andReturn(array('previous' => 'Previous', 'next' => 'Next')) ->shouldReceive('get')->with('validation.attributes.field_name_with_underscore')->andReturn(false) + ->shouldReceive('get')->with('validation.attributes.address.city')->andReturn('City') ->shouldReceive('get')->withAnyArgs()->andReturnUsing(function ($key) { return $key; }) ->shouldReceive('has')->with('field_name_with_underscore')->andReturn(false) + ->shouldReceive('has')->with('address.city')->andReturn(false) + ->shouldReceive('has')->with('address[city]')->andReturn(false) ->shouldReceive('has')->withAnyArgs()->andReturn(true); }); } From 5a40093ca1704492c3fe4f8ede99c1b4bb13ba3f Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Fri, 28 Feb 2014 10:10:52 -0800 Subject: [PATCH 02/32] Instantiate the MethodDispatcher through an IoC container So that MethodDispatcher->addRepository() can be called --- src/Former/FormerServiceProvider.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/Former/FormerServiceProvider.php b/src/Former/FormerServiceProvider.php index c60f61a8..bf5e67e5 100644 --- a/src/Former/FormerServiceProvider.php +++ b/src/Former/FormerServiceProvider.php @@ -160,8 +160,12 @@ public function bindFormer(Container $app) return new Populator; }); + $app->singleton('former.dispatcher', function($app) { + return new MethodDispatcher($app, Former::FIELDSPACE); + }); + $app->singleton('former', function ($app) { - return new Former($app, new MethodDispatcher($app, Former::FIELDSPACE)); + return new Former($app, $app->make('former.dispatcher')); }); Helpers::setApp($app); From 794f89d90ff969ccf849e1c37a2edeb4130e9bd4 Mon Sep 17 00:00:00 2001 From: Maxime Fabre Date: Tue, 11 Mar 2014 20:46:52 +0100 Subject: [PATCH 03/32] Reafect a group's label even when group is present --- composer.lock | 240 +++++++++++++++++++----------------- src/Former/Traits/Field.php | 3 +- 2 files changed, 129 insertions(+), 114 deletions(-) diff --git a/composer.lock b/composer.lock index 7b819c61..e6d1fdde 100644 --- a/composer.lock +++ b/composer.lock @@ -37,7 +37,7 @@ ], "authors": [ { - "name": "Maxime Fabre", + "name": "Anahkiasen", "email": "ehtnam6@gmail.com" } ], @@ -46,17 +46,17 @@ }, { "name": "illuminate/cache", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Cache", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", - "reference": "3f503abfa1cd59457d0b53995e6d560cb2941190" + "reference": "23f7683e29bc44a8deae48bd41acd6243c3ebcd2" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cache/zipball/3f503abfa1cd59457d0b53995e6d560cb2941190", - "reference": "3f503abfa1cd59457d0b53995e6d560cb2941190", + "url": "https://api.github.com/repos/illuminate/cache/zipball/23f7683e29bc44a8deae48bd41acd6243c3ebcd2", + "reference": "23f7683e29bc44a8deae48bd41acd6243c3ebcd2", "shasum": "" }, "require": { @@ -94,21 +94,21 @@ "role": "Developer" } ], - "time": "2014-01-28 15:50:16" + "time": "2014-02-26 20:21:59" }, { "name": "illuminate/config", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Config", "source": { "type": "git", "url": "https://github.com/illuminate/config.git", - "reference": "a646b13c3917f2f527d920171e4f6c9f8cd95c30" + "reference": "fd81e51c0a61023f327616b9d83385386357b363" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/config/zipball/a646b13c3917f2f527d920171e4f6c9f8cd95c30", - "reference": "a646b13c3917f2f527d920171e4f6c9f8cd95c30", + "url": "https://api.github.com/repos/illuminate/config/zipball/fd81e51c0a61023f327616b9d83385386357b363", + "reference": "fd81e51c0a61023f327616b9d83385386357b363", "shasum": "" }, "require": { @@ -142,21 +142,21 @@ "role": "Developer" } ], - "time": "2014-01-19 01:03:20" + "time": "2014-02-09 08:15:59" }, { "name": "illuminate/container", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Container", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "5bc3b7e3227bf6933d382da3cb4631ca1ca63368" + "reference": "80383d49aa1c31f36c95abe582eb8fc779a996fc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/5bc3b7e3227bf6933d382da3cb4631ca1ca63368", - "reference": "5bc3b7e3227bf6933d382da3cb4631ca1ca63368", + "url": "https://api.github.com/repos/illuminate/container/zipball/80383d49aa1c31f36c95abe582eb8fc779a996fc", + "reference": "80383d49aa1c31f36c95abe582eb8fc779a996fc", "shasum": "" }, "require": { @@ -188,21 +188,21 @@ "role": "Developer" } ], - "time": "2014-01-17 01:48:27" + "time": "2014-02-26 18:55:58" }, { "name": "illuminate/cookie", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Cookie", "source": { "type": "git", "url": "https://github.com/illuminate/cookie.git", - "reference": "a608c7d61d80278cb547480c2457397e0aab5072" + "reference": "a13ed37fb668c303960b003201bf9f5260cb9bd6" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cookie/zipball/a608c7d61d80278cb547480c2457397e0aab5072", - "reference": "a608c7d61d80278cb547480c2457397e0aab5072", + "url": "https://api.github.com/repos/illuminate/cookie/zipball/a13ed37fb668c303960b003201bf9f5260cb9bd6", + "reference": "a13ed37fb668c303960b003201bf9f5260cb9bd6", "shasum": "" }, "require": { @@ -213,7 +213,7 @@ "symfony/http-kernel": "2.4.*" }, "require-dev": { - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -239,11 +239,11 @@ "role": "Developer" } ], - "time": "2014-01-18 16:39:57" + "time": "2014-02-28 21:26:20" }, { "name": "illuminate/encryption", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Encryption", "source": { "type": "git", @@ -290,7 +290,7 @@ }, { "name": "illuminate/filesystem", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Filesystem", "source": { "type": "git", @@ -338,17 +338,17 @@ }, { "name": "illuminate/http", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Http", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", - "reference": "e6e03dd17185c9d3b784729cb20011f4a6f1d277" + "reference": "afe11bb00d630f2b0d118d5dd8c22519db011e3d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/http/zipball/e6e03dd17185c9d3b784729cb20011f4a6f1d277", - "reference": "e6e03dd17185c9d3b784729cb20011f4a6f1d277", + "url": "https://api.github.com/repos/illuminate/http/zipball/afe11bb00d630f2b0d118d5dd8c22519db011e3d", + "reference": "afe11bb00d630f2b0d118d5dd8c22519db011e3d", "shasum": "" }, "require": { @@ -358,7 +358,7 @@ "symfony/http-kernel": "2.4.*" }, "require-dev": { - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -384,21 +384,21 @@ "role": "Developer" } ], - "time": "2014-01-31 14:28:12" + "time": "2014-02-28 14:10:51" }, { "name": "illuminate/routing", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Routing", "source": { "type": "git", "url": "https://github.com/illuminate/routing.git", - "reference": "a6ced3ea19e814572d38ba5e5d7dc306bdf907f3" + "reference": "f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/routing/zipball/a6ced3ea19e814572d38ba5e5d7dc306bdf907f3", - "reference": "a6ced3ea19e814572d38ba5e5d7dc306bdf907f3", + "url": "https://api.github.com/repos/illuminate/routing/zipball/f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0", + "reference": "f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0", "shasum": "" }, "require": { @@ -413,7 +413,7 @@ "require-dev": { "illuminate/console": "4.1.*", "illuminate/filesystem": "4.1.*", - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -439,21 +439,21 @@ "role": "Developer" } ], - "time": "2014-02-03 00:38:44" + "time": "2014-02-26 16:29:10" }, { "name": "illuminate/session", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Session", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", - "reference": "d5fec8918d6e388f37a665b2c0e7d451cf8f2a37" + "reference": "8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/session/zipball/d5fec8918d6e388f37a665b2c0e7d451cf8f2a37", - "reference": "d5fec8918d6e388f37a665b2c0e7d451cf8f2a37", + "url": "https://api.github.com/repos/illuminate/session/zipball/8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7", + "reference": "8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7", "shasum": "" }, "require": { @@ -468,7 +468,7 @@ }, "require-dev": { "illuminate/console": "4.1.*", - "mockery/mockery": "0.8.0", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -494,28 +494,29 @@ "role": "Developer" } ], - "time": "2014-02-03 00:38:44" + "time": "2014-02-15 09:27:21" }, { "name": "illuminate/support", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Support", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "f6df9a5d9fac6b5fda1c94d2cd2847346967bdbc" + "reference": "3134bebb9997be4963b320da8b7db2752d7cb937" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/f6df9a5d9fac6b5fda1c94d2cd2847346967bdbc", - "reference": "f6df9a5d9fac6b5fda1c94d2cd2847346967bdbc", + "url": "https://api.github.com/repos/illuminate/support/zipball/3134bebb9997be4963b320da8b7db2752d7cb937", + "reference": "3134bebb9997be4963b320da8b7db2752d7cb937", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "mockery/mockery": "0.7.2", + "jeremeamia/superclosure": "1.0.*", + "mockery/mockery": "0.9.*", "patchwork/utf8": "1.1.*", "phpunit/phpunit": "3.7.*" }, @@ -545,21 +546,21 @@ "role": "Developer" } ], - "time": "2014-01-30 19:59:45" + "time": "2014-02-27 21:11:13" }, { "name": "illuminate/translation", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Translation", "source": { "type": "git", "url": "https://github.com/illuminate/translation.git", - "reference": "0b13c7c45181f0682a2d1f571f57021ffba85d74" + "reference": "140c4c3ded5b73d8240c2361d726ec24d5f3308e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/translation/zipball/0b13c7c45181f0682a2d1f571f57021ffba85d74", - "reference": "0b13c7c45181f0682a2d1f571f57021ffba85d74", + "url": "https://api.github.com/repos/illuminate/translation/zipball/140c4c3ded5b73d8240c2361d726ec24d5f3308e", + "reference": "140c4c3ded5b73d8240c2361d726ec24d5f3308e", "shasum": "" }, "require": { @@ -569,7 +570,7 @@ "symfony/translation": "2.4.*" }, "require-dev": { - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -595,7 +596,7 @@ "role": "Developer" } ], - "time": "2014-01-29 15:55:32" + "time": "2014-02-26 19:02:06" }, { "name": "nesbot/carbon", @@ -683,17 +684,17 @@ }, { "name": "symfony/debug", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Debug", "source": { "type": "git", "url": "https://github.com/symfony/Debug.git", - "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f" + "reference": "23b5f4fcad883679d9a6e1cbc568247fe606d8ee" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", - "reference": "74110be5ec681a83fc5bd66dd5fd29fe85fe9c1f", + "url": "https://api.github.com/repos/symfony/Debug/zipball/23b5f4fcad883679d9a6e1cbc568247fe606d8ee", + "reference": "23b5f4fcad883679d9a6e1cbc568247fe606d8ee", "shasum": "" }, "require": { @@ -725,7 +726,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -734,21 +737,21 @@ ], "description": "Symfony Debug Component", "homepage": "http://symfony.com", - "time": "2014-01-01 09:02:49" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/4708b8cd41984a5ba29fe7dd40716f7f761ac501", + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501", "shasum": "" }, "require": { @@ -779,7 +782,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -788,21 +793,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/finder", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a" + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", + "url": "https://api.github.com/repos/symfony/Finder/zipball/b6735d1fc16da13c4c7dddfe78366a4a098cf011", + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011", "shasum": "" }, "require": { @@ -826,7 +831,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -835,21 +842,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/http-foundation", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844" + "reference": "cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", - "reference": "6c6b8a7bcd7e2cc920cd6acace563fdbf121d844", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129", + "reference": "cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129", "shasum": "" }, "require": { @@ -876,7 +883,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -885,21 +894,21 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:10:50" + "time": "2014-02-11 15:39:28" }, { "name": "symfony/http-kernel", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4" + "reference": "445d6eee0eab2a6cfab41b5dc43f1b86ec34d110" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/0605eedeb52c4d3a3144128d8336395a57be60d4", - "reference": "0605eedeb52c4d3a3144128d8336395a57be60d4", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/445d6eee0eab2a6cfab41b5dc43f1b86ec34d110", + "reference": "445d6eee0eab2a6cfab41b5dc43f1b86ec34d110", "shasum": "" }, "require": { @@ -947,7 +956,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -956,21 +967,21 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:12:11" + "time": "2014-02-12 19:27:03" }, { "name": "symfony/routing", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", "url": "https://github.com/symfony/Routing.git", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a" + "reference": "b2fdea8b60400bb84e4931d71101ebbb3a08c1eb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Routing/zipball/4abfb500aab8be458c9e3a227ea56b190584f78a", - "reference": "4abfb500aab8be458c9e3a227ea56b190584f78a", + "url": "https://api.github.com/repos/symfony/Routing/zipball/b2fdea8b60400bb84e4931d71101ebbb3a08c1eb", + "reference": "b2fdea8b60400bb84e4931d71101ebbb3a08c1eb", "shasum": "" }, "require": { @@ -1007,7 +1018,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -1022,21 +1035,21 @@ "uri", "url" ], - "time": "2014-01-05 02:10:50" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/translation", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "7f76dffd7eaf2c9a3a8f47649404c71440d18c8b" + "reference": "b00fd07417e493e08488e87bcebeb9681fc7323b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/7f76dffd7eaf2c9a3a8f47649404c71440d18c8b", - "reference": "7f76dffd7eaf2c9a3a8f47649404c71440d18c8b", + "url": "https://api.github.com/repos/symfony/Translation/zipball/b00fd07417e493e08488e87bcebeb9681fc7323b", + "reference": "b00fd07417e493e08488e87bcebeb9681fc7323b", "shasum": "" }, "require": { @@ -1068,7 +1081,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -1077,23 +1092,23 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2013-12-31 13:43:26" + "time": "2014-02-03 17:15:33" } ], "packages-dev": [ { "name": "illuminate/database", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Database", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "a4e6d1a61ccc3fe0eaa1d9d6a9cc9cf9f07e5b8f" + "reference": "d695cb6fa8d05501ba402e16d63fce77b5f29f69" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/a4e6d1a61ccc3fe0eaa1d9d6a9cc9cf9f07e5b8f", - "reference": "a4e6d1a61ccc3fe0eaa1d9d6a9cc9cf9f07e5b8f", + "url": "https://api.github.com/repos/illuminate/database/zipball/d695cb6fa8d05501ba402e16d63fce77b5f29f69", + "reference": "d695cb6fa8d05501ba402e16d63fce77b5f29f69", "shasum": "" }, "require": { @@ -1109,7 +1124,7 @@ "illuminate/filesystem": "4.1.*", "illuminate/pagination": "4.1.*", "illuminate/support": "4.1.*", - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -1141,21 +1156,21 @@ "orm", "sql" ], - "time": "2014-01-31 14:47:11" + "time": "2014-02-28 20:28:45" }, { "name": "illuminate/events", - "version": "v4.1.21", + "version": "v4.1.23", "target-dir": "Illuminate/Events", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", - "reference": "f07a516087bf05e216af01c0cb046983d101a6cd" + "reference": "357150eeb29fb9248e0c5fd464098955a61dcbcc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/events/zipball/f07a516087bf05e216af01c0cb046983d101a6cd", - "reference": "f07a516087bf05e216af01c0cb046983d101a6cd", + "url": "https://api.github.com/repos/illuminate/events/zipball/357150eeb29fb9248e0c5fd464098955a61dcbcc", + "reference": "357150eeb29fb9248e0c5fd464098955a61dcbcc", "shasum": "" }, "require": { @@ -1164,7 +1179,7 @@ "php": ">=5.3.0" }, "require-dev": { - "mockery/mockery": "0.7.2", + "mockery/mockery": "0.9.*", "phpunit/phpunit": "3.7.*" }, "type": "library", @@ -1190,7 +1205,7 @@ "role": "Developer" } ], - "time": "2014-01-17 20:11:45" + "time": "2014-02-15 09:27:21" }, { "name": "mockery/mockery", @@ -1198,12 +1213,12 @@ "source": { "type": "git", "url": "https://github.com/padraic/mockery.git", - "reference": "a060e069b4f46159906296d25ae80c6b0fec8daf" + "reference": "a32c6ad986c061b40636b7da4fe30adc2a7451b5" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/padraic/mockery/zipball/a060e069b4f46159906296d25ae80c6b0fec8daf", - "reference": "a060e069b4f46159906296d25ae80c6b0fec8daf", + "url": "https://api.github.com/repos/padraic/mockery/zipball/a32c6ad986c061b40636b7da4fe30adc2a7451b5", + "reference": "a32c6ad986c061b40636b7da4fe30adc2a7451b5", "shasum": "" }, "require": { @@ -1212,6 +1227,7 @@ }, "require-dev": { "hamcrest/hamcrest-php": "~1.1", + "phpunit/phpunit": "4.0.*", "satooshi/php-coveralls": "dev-master" }, "type": "library", @@ -1255,7 +1271,7 @@ "test double", "testing" ], - "time": "2014-02-08 11:17:53" + "time": "2014-03-05 22:17:02" } ], "aliases": [ diff --git a/src/Former/Traits/Field.php b/src/Former/Traits/Field.php index cd23d55c..a04f6e9a 100644 --- a/src/Former/Traits/Field.php +++ b/src/Former/Traits/Field.php @@ -266,10 +266,9 @@ public function label($text, $attributes = array()) $label = $this->app['former']->label($text, $for, $attributes); // Set label + $this->label = $label; if ($this->group) { $this->group->setLabel($label); - } else { - $this->label = $label; } return $this; From 6f3123970afbc247f3481e7b195e425c51598aba Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Mon, 17 Mar 2014 11:18:00 -0700 Subject: [PATCH 04/32] Allow specific checkboxes to override the global push_checkboxes My use case is that you've set the `push_checkboxes` config option to true, but there is a single checkbox instances you want to **not** push checkboxes. This change makes it so a checkbox will push a hidden field only if the global config is set AND the checkbox hasn't been explicitly set to not push. --- src/Former/Traits/Checkable.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Former/Traits/Checkable.php b/src/Former/Traits/Checkable.php index fef83d96..69ce724f 100644 --- a/src/Former/Traits/Checkable.php +++ b/src/Former/Traits/Checkable.php @@ -66,7 +66,7 @@ abstract class Checkable extends Field * * @var boolean */ - protected $isPushed = false; + protected $isPushed = null; //////////////////////////////////////////////////////////////////// //////////////////////////// CORE METHODS ////////////////////////// @@ -325,7 +325,7 @@ protected function createCheckable($item, $fallbackValue = 1) // Add hidden checkbox if requested if ($this->isOfType('checkbox', 'checkboxes')) { - if ($this->app['former']->getOption('push_checkboxes') or $this->isPushed) { + if ($this->app['former']->getOption('push_checkboxes') and $this->isPushed !== false) { $field = $this->app['former']->hidden($name)->forceValue($this->app['former']->getOption('unchecked_value')) . $field->render(); } } From 38db61763b86000203017460b6ddf2018dcf2611 Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Mon, 17 Mar 2014 11:49:28 -0700 Subject: [PATCH 05/32] Fixing issue revealed by Travis test --- src/Former/Traits/Checkable.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Former/Traits/Checkable.php b/src/Former/Traits/Checkable.php index 69ce724f..d55f7074 100644 --- a/src/Former/Traits/Checkable.php +++ b/src/Former/Traits/Checkable.php @@ -325,7 +325,7 @@ protected function createCheckable($item, $fallbackValue = 1) // Add hidden checkbox if requested if ($this->isOfType('checkbox', 'checkboxes')) { - if ($this->app['former']->getOption('push_checkboxes') and $this->isPushed !== false) { + if ($this->isPushed or ($this->app['former']->getOption('push_checkboxes') and $this->isPushed !== false)) { $field = $this->app['former']->hidden($name)->forceValue($this->app['former']->getOption('unchecked_value')) . $field->render(); } } From fd385eb385f669e5393bb55fa3d401e2b183b493 Mon Sep 17 00:00:00 2001 From: Robert Reinhard Date: Mon, 17 Mar 2014 11:53:36 -0700 Subject: [PATCH 06/32] Adding a test for overriding globally pushed checkboxes --- tests/Fields/CheckboxTest.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/tests/Fields/CheckboxTest.php b/tests/Fields/CheckboxTest.php index 333600d6..899f1c99 100644 --- a/tests/Fields/CheckboxTest.php +++ b/tests/Fields/CheckboxTest.php @@ -263,6 +263,19 @@ public function testCanPushUncheckedCheckboxes() $this->assertEquals($matcher, $checkbox->wrapAndRender()); } + public function testCanOverrideGloballyPushedCheckboxes() + { + $this->mockConfig(array('push_checkboxes' => true)); + $checkbox = $this->former->checkbox('foo')->text('foo')->push(false); + + $matcher = $this->controlGroup( + ''); + + $this->assertEquals($matcher, $checkbox->wrapAndRender()); + } + public function testCanPushASingleCheckbox() { $this->mockConfig(array('push_checkboxes' => true)); From 3aee832ae0af8bc10ed5e81c740599e096e48c77 Mon Sep 17 00:00:00 2001 From: Graham Campbell Date: Sat, 5 Apr 2014 16:32:56 +0100 Subject: [PATCH 07/32] Composer updates --- composer.json | 21 +++-- composer.lock | 232 +++++++++++++++++++++++++------------------------- 2 files changed, 127 insertions(+), 126 deletions(-) diff --git a/composer.json b/composer.json index 6e730f5c..bc421d02 100644 --- a/composer.json +++ b/composer.json @@ -16,17 +16,17 @@ } ], "require": { - "anahkiasen/html-object": "1.*", - "illuminate/config": "~4", - "illuminate/container": "~4", - "illuminate/http": "~4", - "illuminate/routing": "~4", - "illuminate/session": "~4", - "illuminate/translation" :"~4" + "anahkiasen/html-object": "~1.4", + "illuminate/config": "~4.0", + "illuminate/container": "~4.0", + "illuminate/http": "~4.0", + "illuminate/routing": "~4.0", + "illuminate/session": "~4.0", + "illuminate/translation" :"~4.0" }, "require-dev": { - "mockery/mockery": "dev-master", - "illuminate/database": "~4" + "mockery/mockery": "~0.9", + "illuminate/database": "~4.0" }, "autoload": { "psr-0": { @@ -34,6 +34,5 @@ "Laravel": "src" }, "classmap": ["tests"] - }, - "minimum-stability": "stable" + } } diff --git a/composer.lock b/composer.lock index e6d1fdde..172e0d1b 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "3143423a586f66ced8a85116303558fc", + "hash": "107408e0ec86a74cc70df69ecafed427", "packages": [ { "name": "anahkiasen/html-object", @@ -46,17 +46,17 @@ }, { "name": "illuminate/cache", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Cache", "source": { "type": "git", "url": "https://github.com/illuminate/cache.git", - "reference": "23f7683e29bc44a8deae48bd41acd6243c3ebcd2" + "reference": "96953226a11ddda8b740266b41c667fb787aff3f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cache/zipball/23f7683e29bc44a8deae48bd41acd6243c3ebcd2", - "reference": "23f7683e29bc44a8deae48bd41acd6243c3ebcd2", + "url": "https://api.github.com/repos/illuminate/cache/zipball/96953226a11ddda8b740266b41c667fb787aff3f", + "reference": "96953226a11ddda8b740266b41c667fb787aff3f", "shasum": "" }, "require": { @@ -69,7 +69,7 @@ "illuminate/encryption": "4.1.*", "illuminate/filesystem": "4.1.*", "illuminate/redis": "4.1.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -94,21 +94,21 @@ "role": "Developer" } ], - "time": "2014-02-26 20:21:59" + "time": "2014-03-04 22:56:43" }, { "name": "illuminate/config", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Config", "source": { "type": "git", "url": "https://github.com/illuminate/config.git", - "reference": "fd81e51c0a61023f327616b9d83385386357b363" + "reference": "878a0817c9bf300f72043dd5cdb71785a85547de" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/config/zipball/fd81e51c0a61023f327616b9d83385386357b363", - "reference": "fd81e51c0a61023f327616b9d83385386357b363", + "url": "https://api.github.com/repos/illuminate/config/zipball/878a0817c9bf300f72043dd5cdb71785a85547de", + "reference": "878a0817c9bf300f72043dd5cdb71785a85547de", "shasum": "" }, "require": { @@ -117,7 +117,7 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -142,28 +142,28 @@ "role": "Developer" } ], - "time": "2014-02-09 08:15:59" + "time": "2014-03-04 22:56:43" }, { "name": "illuminate/container", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Container", "source": { "type": "git", "url": "https://github.com/illuminate/container.git", - "reference": "80383d49aa1c31f36c95abe582eb8fc779a996fc" + "reference": "2e2e14d50feb924de7c0a81843fe617dd94aadec" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/container/zipball/80383d49aa1c31f36c95abe582eb8fc779a996fc", - "reference": "80383d49aa1c31f36c95abe582eb8fc779a996fc", + "url": "https://api.github.com/repos/illuminate/container/zipball/2e2e14d50feb924de7c0a81843fe617dd94aadec", + "reference": "2e2e14d50feb924de7c0a81843fe617dd94aadec", "shasum": "" }, "require": { "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -188,21 +188,21 @@ "role": "Developer" } ], - "time": "2014-02-26 18:55:58" + "time": "2014-03-07 14:45:01" }, { "name": "illuminate/cookie", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Cookie", "source": { "type": "git", "url": "https://github.com/illuminate/cookie.git", - "reference": "a13ed37fb668c303960b003201bf9f5260cb9bd6" + "reference": "8c3617bf2153fd6d5ab93ca39d6a1001706d445e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/cookie/zipball/a13ed37fb668c303960b003201bf9f5260cb9bd6", - "reference": "a13ed37fb668c303960b003201bf9f5260cb9bd6", + "url": "https://api.github.com/repos/illuminate/cookie/zipball/8c3617bf2153fd6d5ab93ca39d6a1001706d445e", + "reference": "8c3617bf2153fd6d5ab93ca39d6a1001706d445e", "shasum": "" }, "require": { @@ -214,7 +214,7 @@ }, "require-dev": { "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -239,21 +239,21 @@ "role": "Developer" } ], - "time": "2014-02-28 21:26:20" + "time": "2014-03-04 22:56:43" }, { "name": "illuminate/encryption", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Encryption", "source": { "type": "git", "url": "https://github.com/illuminate/encryption.git", - "reference": "a7ded5e5fee4685c94b9bfb8b1c74b0750f4e23b" + "reference": "7ee93e26746e19cf992b17f5f595371d435679dc" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/encryption/zipball/a7ded5e5fee4685c94b9bfb8b1c74b0750f4e23b", - "reference": "a7ded5e5fee4685c94b9bfb8b1c74b0750f4e23b", + "url": "https://api.github.com/repos/illuminate/encryption/zipball/7ee93e26746e19cf992b17f5f595371d435679dc", + "reference": "7ee93e26746e19cf992b17f5f595371d435679dc", "shasum": "" }, "require": { @@ -261,7 +261,7 @@ "php": ">=5.3.0" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -286,21 +286,21 @@ "role": "Developer" } ], - "time": "2014-01-17 20:11:45" + "time": "2014-03-04 22:56:43" }, { "name": "illuminate/filesystem", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Filesystem", "source": { "type": "git", "url": "https://github.com/illuminate/filesystem.git", - "reference": "74b51ab0355f36ea84de74ddada1c56cd15eed5d" + "reference": "8490569e31c5bebcbf453a468e9ae4bedd0837d7" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/filesystem/zipball/74b51ab0355f36ea84de74ddada1c56cd15eed5d", - "reference": "74b51ab0355f36ea84de74ddada1c56cd15eed5d", + "url": "https://api.github.com/repos/illuminate/filesystem/zipball/8490569e31c5bebcbf453a468e9ae4bedd0837d7", + "reference": "8490569e31c5bebcbf453a468e9ae4bedd0837d7", "shasum": "" }, "require": { @@ -309,7 +309,7 @@ "symfony/finder": "2.4.*" }, "require-dev": { - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -334,21 +334,21 @@ "role": "Developer" } ], - "time": "2014-01-17 18:08:13" + "time": "2014-03-04 22:56:43" }, { "name": "illuminate/http", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Http", "source": { "type": "git", "url": "https://github.com/illuminate/http.git", - "reference": "afe11bb00d630f2b0d118d5dd8c22519db011e3d" + "reference": "43a3e62c6ac98f94473924aeb9a8bacf42c911a4" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/http/zipball/afe11bb00d630f2b0d118d5dd8c22519db011e3d", - "reference": "afe11bb00d630f2b0d118d5dd8c22519db011e3d", + "url": "https://api.github.com/repos/illuminate/http/zipball/43a3e62c6ac98f94473924aeb9a8bacf42c911a4", + "reference": "43a3e62c6ac98f94473924aeb9a8bacf42c911a4", "shasum": "" }, "require": { @@ -359,7 +359,7 @@ }, "require-dev": { "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -384,21 +384,21 @@ "role": "Developer" } ], - "time": "2014-02-28 14:10:51" + "time": "2014-03-10 20:00:02" }, { "name": "illuminate/routing", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Routing", "source": { "type": "git", "url": "https://github.com/illuminate/routing.git", - "reference": "f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0" + "reference": "4a9721fc0e11f464942606e8f9b915eab7cd45ae" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/routing/zipball/f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0", - "reference": "f988dc49d1cba63ccb7aa12e61cc4fb9024e81f0", + "url": "https://api.github.com/repos/illuminate/routing/zipball/4a9721fc0e11f464942606e8f9b915eab7cd45ae", + "reference": "4a9721fc0e11f464942606e8f9b915eab7cd45ae", "shasum": "" }, "require": { @@ -414,7 +414,7 @@ "illuminate/console": "4.1.*", "illuminate/filesystem": "4.1.*", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -439,21 +439,21 @@ "role": "Developer" } ], - "time": "2014-02-26 16:29:10" + "time": "2014-03-07 14:45:01" }, { "name": "illuminate/session", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Session", "source": { "type": "git", "url": "https://github.com/illuminate/session.git", - "reference": "8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7" + "reference": "2e646cbfc0032c460e02441f41413f42178ba781" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/session/zipball/8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7", - "reference": "8cbd3cb0a08d1b2ea02c207a93d6f89a56dea7a7", + "url": "https://api.github.com/repos/illuminate/session/zipball/2e646cbfc0032c460e02441f41413f42178ba781", + "reference": "2e646cbfc0032c460e02441f41413f42178ba781", "shasum": "" }, "require": { @@ -469,7 +469,7 @@ "require-dev": { "illuminate/console": "4.1.*", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -494,21 +494,21 @@ "role": "Developer" } ], - "time": "2014-02-15 09:27:21" + "time": "2014-03-13 11:43:48" }, { "name": "illuminate/support", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Support", "source": { "type": "git", "url": "https://github.com/illuminate/support.git", - "reference": "3134bebb9997be4963b320da8b7db2752d7cb937" + "reference": "ff32e707fa8b6e975ee46e5277b6270ec2f7029f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/support/zipball/3134bebb9997be4963b320da8b7db2752d7cb937", - "reference": "3134bebb9997be4963b320da8b7db2752d7cb937", + "url": "https://api.github.com/repos/illuminate/support/zipball/ff32e707fa8b6e975ee46e5277b6270ec2f7029f", + "reference": "ff32e707fa8b6e975ee46e5277b6270ec2f7029f", "shasum": "" }, "require": { @@ -518,7 +518,7 @@ "jeremeamia/superclosure": "1.0.*", "mockery/mockery": "0.9.*", "patchwork/utf8": "1.1.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -546,21 +546,21 @@ "role": "Developer" } ], - "time": "2014-02-27 21:11:13" + "time": "2014-03-13 01:02:42" }, { "name": "illuminate/translation", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Translation", "source": { "type": "git", "url": "https://github.com/illuminate/translation.git", - "reference": "140c4c3ded5b73d8240c2361d726ec24d5f3308e" + "reference": "16fb63bda01a9aa2a5bbfa514d2e4552f08d7f78" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/translation/zipball/140c4c3ded5b73d8240c2361d726ec24d5f3308e", - "reference": "140c4c3ded5b73d8240c2361d726ec24d5f3308e", + "url": "https://api.github.com/repos/illuminate/translation/zipball/16fb63bda01a9aa2a5bbfa514d2e4552f08d7f78", + "reference": "16fb63bda01a9aa2a5bbfa514d2e4552f08d7f78", "shasum": "" }, "require": { @@ -571,7 +571,7 @@ }, "require-dev": { "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -596,7 +596,7 @@ "role": "Developer" } ], - "time": "2014-02-26 19:02:06" + "time": "2014-03-04 22:56:43" }, { "name": "nesbot/carbon", @@ -684,17 +684,17 @@ }, { "name": "symfony/debug", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/Debug", "source": { "type": "git", "url": "https://github.com/symfony/Debug.git", - "reference": "23b5f4fcad883679d9a6e1cbc568247fe606d8ee" + "reference": "cf012d37f7e0d059fd6b35607e99761b33ccf4ed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Debug/zipball/23b5f4fcad883679d9a6e1cbc568247fe606d8ee", - "reference": "23b5f4fcad883679d9a6e1cbc568247fe606d8ee", + "url": "https://api.github.com/repos/symfony/Debug/zipball/cf012d37f7e0d059fd6b35607e99761b33ccf4ed", + "reference": "cf012d37f7e0d059fd6b35607e99761b33ccf4ed", "shasum": "" }, "require": { @@ -737,11 +737,11 @@ ], "description": "Symfony Debug Component", "homepage": "http://symfony.com", - "time": "2014-02-11 13:52:09" + "time": "2014-03-26 18:07:42" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", @@ -797,17 +797,17 @@ }, { "name": "symfony/finder", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011" + "reference": "ab301c7d21f536c34ab6c2c79dba8d465104c518" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/b6735d1fc16da13c4c7dddfe78366a4a098cf011", - "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011", + "url": "https://api.github.com/repos/symfony/Finder/zipball/ab301c7d21f536c34ab6c2c79dba8d465104c518", + "reference": "ab301c7d21f536c34ab6c2c79dba8d465104c518", "shasum": "" }, "require": { @@ -842,26 +842,29 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-01-07 13:28:54" + "time": "2014-03-01 17:35:04" }, { "name": "symfony/http-foundation", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/HttpFoundation", "source": { "type": "git", "url": "https://github.com/symfony/HttpFoundation.git", - "reference": "cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129" + "reference": "11ad7352c7bfa12145a0df8e1c4c303c585ce169" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129", - "reference": "cdee7c84ba8b2a8aafa1c055f5cb4f640d81c129", + "url": "https://api.github.com/repos/symfony/HttpFoundation/zipball/11ad7352c7bfa12145a0df8e1c4c303c585ce169", + "reference": "11ad7352c7bfa12145a0df8e1c4c303c585ce169", "shasum": "" }, "require": { "php": ">=5.3.3" }, + "require-dev": { + "symfony/expression-language": "~2.4" + }, "type": "library", "extra": { "branch-alias": { @@ -894,21 +897,21 @@ ], "description": "Symfony HttpFoundation Component", "homepage": "http://symfony.com", - "time": "2014-02-11 15:39:28" + "time": "2014-03-26 11:35:33" }, { "name": "symfony/http-kernel", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/HttpKernel", "source": { "type": "git", "url": "https://github.com/symfony/HttpKernel.git", - "reference": "445d6eee0eab2a6cfab41b5dc43f1b86ec34d110" + "reference": "f4e3f0fd1a08c1c4e2ffa044e6910f7ecc7ad317" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/445d6eee0eab2a6cfab41b5dc43f1b86ec34d110", - "reference": "445d6eee0eab2a6cfab41b5dc43f1b86ec34d110", + "url": "https://api.github.com/repos/symfony/HttpKernel/zipball/f4e3f0fd1a08c1c4e2ffa044e6910f7ecc7ad317", + "reference": "f4e3f0fd1a08c1c4e2ffa044e6910f7ecc7ad317", "shasum": "" }, "require": { @@ -967,11 +970,11 @@ ], "description": "Symfony HttpKernel Component", "homepage": "http://symfony.com", - "time": "2014-02-12 19:27:03" + "time": "2014-04-04 10:27:02" }, { "name": "symfony/routing", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/Routing", "source": { "type": "git", @@ -1039,17 +1042,17 @@ }, { "name": "symfony/translation", - "version": "v2.4.2", + "version": "v2.4.3", "target-dir": "Symfony/Component/Translation", "source": { "type": "git", "url": "https://github.com/symfony/Translation.git", - "reference": "b00fd07417e493e08488e87bcebeb9681fc7323b" + "reference": "98697a79a0db83d6f9a3a609a0704f02571ab46c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Translation/zipball/b00fd07417e493e08488e87bcebeb9681fc7323b", - "reference": "b00fd07417e493e08488e87bcebeb9681fc7323b", + "url": "https://api.github.com/repos/symfony/Translation/zipball/98697a79a0db83d6f9a3a609a0704f02571ab46c", + "reference": "98697a79a0db83d6f9a3a609a0704f02571ab46c", "shasum": "" }, "require": { @@ -1092,23 +1095,23 @@ ], "description": "Symfony Translation Component", "homepage": "http://symfony.com", - "time": "2014-02-03 17:15:33" + "time": "2014-03-26 11:35:33" } ], "packages-dev": [ { "name": "illuminate/database", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Database", "source": { "type": "git", "url": "https://github.com/illuminate/database.git", - "reference": "d695cb6fa8d05501ba402e16d63fce77b5f29f69" + "reference": "f59ff31c5e2c1cb30bb7064a20819e53d676784b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/database/zipball/d695cb6fa8d05501ba402e16d63fce77b5f29f69", - "reference": "d695cb6fa8d05501ba402e16d63fce77b5f29f69", + "url": "https://api.github.com/repos/illuminate/database/zipball/f59ff31c5e2c1cb30bb7064a20819e53d676784b", + "reference": "f59ff31c5e2c1cb30bb7064a20819e53d676784b", "shasum": "" }, "require": { @@ -1125,7 +1128,7 @@ "illuminate/pagination": "4.1.*", "illuminate/support": "4.1.*", "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -1156,21 +1159,21 @@ "orm", "sql" ], - "time": "2014-02-28 20:28:45" + "time": "2014-03-16 17:25:49" }, { "name": "illuminate/events", - "version": "v4.1.23", + "version": "v4.1.24", "target-dir": "Illuminate/Events", "source": { "type": "git", "url": "https://github.com/illuminate/events.git", - "reference": "357150eeb29fb9248e0c5fd464098955a61dcbcc" + "reference": "e7ab5a682832c1e8c76b724158b1524353d6cfd1" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/illuminate/events/zipball/357150eeb29fb9248e0c5fd464098955a61dcbcc", - "reference": "357150eeb29fb9248e0c5fd464098955a61dcbcc", + "url": "https://api.github.com/repos/illuminate/events/zipball/e7ab5a682832c1e8c76b724158b1524353d6cfd1", + "reference": "e7ab5a682832c1e8c76b724158b1524353d6cfd1", "shasum": "" }, "require": { @@ -1180,7 +1183,7 @@ }, "require-dev": { "mockery/mockery": "0.9.*", - "phpunit/phpunit": "3.7.*" + "phpunit/phpunit": "4.0.*" }, "type": "library", "extra": { @@ -1205,20 +1208,20 @@ "role": "Developer" } ], - "time": "2014-02-15 09:27:21" + "time": "2014-03-04 22:56:43" }, { "name": "mockery/mockery", - "version": "dev-master", + "version": "0.9.0", "source": { "type": "git", "url": "https://github.com/padraic/mockery.git", - "reference": "a32c6ad986c061b40636b7da4fe30adc2a7451b5" + "reference": "0fd49fd3f6c984409802004b1dd7b55d0f35ce4a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/padraic/mockery/zipball/a32c6ad986c061b40636b7da4fe30adc2a7451b5", - "reference": "a32c6ad986c061b40636b7da4fe30adc2a7451b5", + "url": "https://api.github.com/repos/padraic/mockery/zipball/0fd49fd3f6c984409802004b1dd7b55d0f35ce4a", + "reference": "0fd49fd3f6c984409802004b1dd7b55d0f35ce4a", "shasum": "" }, "require": { @@ -1227,7 +1230,6 @@ }, "require-dev": { "hamcrest/hamcrest-php": "~1.1", - "phpunit/phpunit": "4.0.*", "satooshi/php-coveralls": "dev-master" }, "type": "library", @@ -1271,16 +1273,16 @@ "test double", "testing" ], - "time": "2014-03-05 22:17:02" + "time": "2014-02-05 21:30:08" } ], "aliases": [ ], "minimum-stability": "stable", - "stability-flags": { - "mockery/mockery": 20 - }, + "stability-flags": [ + + ], "platform": [ ], From 7b79b5266c783b4d8c9e3b8063fe8cd44ea6bc7e Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Wed, 9 Apr 2014 13:11:21 -0700 Subject: [PATCH 08/32] changing inline help in ZurbFoundation and ZurbFoundation4 so that form validation help text can be styled properly (like Bootstrap) --- src/Former/Framework/ZurbFoundation.php | 2 +- src/Former/Framework/ZurbFoundation4.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Former/Framework/ZurbFoundation.php b/src/Former/Framework/ZurbFoundation.php index c1303561..49bcb6bc 100644 --- a/src/Former/Framework/ZurbFoundation.php +++ b/src/Former/Framework/ZurbFoundation.php @@ -156,7 +156,7 @@ public function getActionClasses() public function createHelp($text, $attributes = array()) { - return Element::create('small', $text, $attributes); + return Element::create('span', $text, $attributes); } /** diff --git a/src/Former/Framework/ZurbFoundation4.php b/src/Former/Framework/ZurbFoundation4.php index bc56b75e..413a21be 100644 --- a/src/Former/Framework/ZurbFoundation4.php +++ b/src/Former/Framework/ZurbFoundation4.php @@ -158,7 +158,7 @@ public function getActionClasses() public function createHelp($text, $attributes = '') { - return Element::create('small', $text, $attributes); + return Element::create('span', $text, $attributes); } /** From 82e1c48ca81c237d814f078ef5c36f7f7034046c Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Wed, 9 Apr 2014 15:17:34 -0700 Subject: [PATCH 09/32] add framework option to ZurbFoundation4 to allow setting of validation alert styles --- src/Former/Framework/ZurbFoundation4.php | 8 ++++++-- src/config/ZurbFoundation4.php | 3 +++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/Former/Framework/ZurbFoundation4.php b/src/Former/Framework/ZurbFoundation4.php index 413a21be..70ea4cff 100644 --- a/src/Former/Framework/ZurbFoundation4.php +++ b/src/Former/Framework/ZurbFoundation4.php @@ -156,9 +156,13 @@ public function getActionClasses() //////////////////////////// RENDER BLOCKS ///////////////////////// //////////////////////////////////////////////////////////////////// - public function createHelp($text, $attributes = '') + public function createHelp($text, $attributes = null) { - return Element::create('span', $text, $attributes); + if ($attributes == null) + { + $attributes = $this->getFrameworkOption('error_classes'); + } + return Element::create('span', $text, $attributes); } /** diff --git a/src/config/ZurbFoundation4.php b/src/config/ZurbFoundation4.php index f5d77c46..a1eb050c 100644 --- a/src/config/ZurbFoundation4.php +++ b/src/config/ZurbFoundation4.php @@ -28,4 +28,7 @@ 'prefix' => 'foundicon', ), + // CSS for inline validation errors + 'error_classes' => array ( 'class' => 'alert-box radius warning' ) + ); From 0f625b7371fd861a0f50e50a6aa76d6de8a1fb22 Mon Sep 17 00:00:00 2001 From: Ben Claar Date: Fri, 11 Apr 2014 17:15:41 -0500 Subject: [PATCH 10/32] Fix unit tests. --- tests/Framework/ZurbFramework4Test.php | 2 +- tests/Framework/ZurbFrameworkTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Framework/ZurbFramework4Test.php b/tests/Framework/ZurbFramework4Test.php index b2818e0e..684fbb0a 100644 --- a/tests/Framework/ZurbFramework4Test.php +++ b/tests/Framework/ZurbFramework4Test.php @@ -50,7 +50,7 @@ public function testCanSetAnErrorStateOnAField() public function testCanAppendHelpTexts() { $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); - $matcher = array('tag' => 'small', 'content' => 'Bar'); + $matcher = array('tag' => 'span', 'content' => 'Bar'); $this->assertLabel($input); $this->assertHTML($this->matchField(), $input); diff --git a/tests/Framework/ZurbFrameworkTest.php b/tests/Framework/ZurbFrameworkTest.php index d90eb77f..c166da01 100644 --- a/tests/Framework/ZurbFrameworkTest.php +++ b/tests/Framework/ZurbFrameworkTest.php @@ -49,7 +49,7 @@ public function testCanSetAnErrorStateOnAField() public function testCanAppendHelpTexts() { $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); - $matcher = array('tag' => 'small', 'content' => 'Bar'); + $matcher = array('tag' => 'span', 'content' => 'Bar'); $this->assertLabel($input); $this->assertHTML($this->matchField(), $input); From c481cff6515279fbcfa02658a34d6543bfbb478c Mon Sep 17 00:00:00 2001 From: Ben Claar Date: Fri, 11 Apr 2014 21:26:17 -0500 Subject: [PATCH 11/32] Fix grouped checkbox repopulating from POST and the Populator. --- src/Former/Form/Fields/Checkbox.php | 4 + src/Former/Traits/Checkable.php | 49 ++++++++++-- tests/Fields/CheckboxTest.php | 113 ++++++++++++++++++++++++++-- 3 files changed, 154 insertions(+), 12 deletions(-) diff --git a/src/Former/Form/Fields/Checkbox.php b/src/Former/Form/Fields/Checkbox.php index 3045a2f0..1eac8ab0 100644 --- a/src/Former/Form/Fields/Checkbox.php +++ b/src/Former/Form/Fields/Checkbox.php @@ -24,6 +24,10 @@ class Checkbox extends Checkable */ public function checkboxes() { + if ($this->isGrouped()) { + // Remove any possible items added by the Populator. + $this->items = array(); + } $this->items(func_get_args()); return $this; diff --git a/src/Former/Traits/Checkable.php b/src/Former/Traits/Checkable.php index d55f7074..f5749c7f 100644 --- a/src/Former/Traits/Checkable.php +++ b/src/Former/Traits/Checkable.php @@ -77,6 +77,11 @@ abstract class Checkable extends Field */ public function __construct(Container $app, $type, $name, $label, $value, $attributes) { + // Unify auto and chained methods of grouping checkboxes + if (ends_with($name,'[]')) { + $name = substr($name, 0, -2); + $this->grouped(); + } parent::__construct($app, $type, $name, $label, $value, $attributes); if (is_array($this->value)) { @@ -233,6 +238,7 @@ protected function items($_items) { // If passing an array if (sizeof($_items) == 1 and + isset($_items[0]) and is_array($_items[0])) { $_items = $_items[0]; } @@ -275,6 +281,7 @@ protected function items($_items) $item = array( 'name' => $name, 'label' => Helpers::translate($label), + 'count' => $count, ); if (isset($attributes)) { $item['attributes'] = $attributes; @@ -319,7 +326,7 @@ protected function createCheckable($item, $fallbackValue = 1) // Create field $field = Input::create($this->checkable, $name, $value, $attributes); - if ($this->isChecked($name, $value)) { + if ($this->isChecked($item, $value)) { $field->checked('checked'); } @@ -388,9 +395,12 @@ protected function setOnFocused($attribute, $value) * * @return boolean Checked or not */ - protected function isChecked($name = null, $value = null) + protected function isChecked($item = null, $value = null) { - if (!$name) { + if (isset($item['name'])) { + $name = $item['name']; + } + if (empty($name)) { $name = $this->name; } @@ -407,8 +417,24 @@ protected function isChecked($name = null, $value = null) } // Check the values and POST array - $post = $this->app['former']->getPost($name); - $static = $this->app['former']->getValue($name); + if ($this->isGrouped()) { + $groupIndex = self::getGroupIndexFromItem($item); + + // Search using the bare name, not the individual item name + $post = $this->app['former']->getPost($this->name); + $static = $this->app['former']->getValue($this->name); + + if (isset($post[$groupIndex])) { + $post = $post[$groupIndex]; + } + if (isset($static[$groupIndex])) { + $static = $static[$groupIndex]; + } + + } else { + $post = $this->app['former']->getPost($name); + $static = $this->app['former']->getValue($name); + } if (!is_null($post) and $post !== $this->app['former']->getOption('unchecked_value')) { $isChecked = ($post == $value); @@ -442,4 +468,17 @@ protected function isGrouped() $this->grouped == true or strpos($this->name, '[]') !== false; } + + /** + * @param array $item The item array, containing at least name and count keys. + * @return mixed The group index. (e.g. returns bar if the item name is foo[bar], or the item count for foo[]) + */ + public static function getGroupIndexFromItem($item) + { + $groupIndex = preg_replace('/^.*?\[(.*)\]$/', '$1', $item['name']); + if (empty($groupIndex) or $groupIndex == $item['name']) { + return $item['count']; + } + return $groupIndex; + } } diff --git a/tests/Fields/CheckboxTest.php b/tests/Fields/CheckboxTest.php index 899f1c99..f611ac91 100644 --- a/tests/Fields/CheckboxTest.php +++ b/tests/Fields/CheckboxTest.php @@ -322,21 +322,120 @@ public function testCanGroupCheckboxes() '', $auto); } + + public function testCanCustomizeGroupedCheckboxes() + { + $this->former->framework('Nude'); + + $checkboxes = array( + 'Value 01' => array( + 'id' => 'value[foo_id]', + 'name' => 'value[foo_name]', + 'value' => 'foo_value', + ), + 'Value 02' => array( + 'id' => 'value[bar_id]', + 'name' => 'value[bar_name]', + 'value' => 'bar_value', + ), + ); + + $this->former->populate(array('value' => array('foo_name' => 'foo_value'))); + $auto = $this->former->checkboxes('value[]', '')->checkboxes($checkboxes)->__toString(); + $chain = $this->former->checkboxes('value', '')->grouped()->checkboxes($checkboxes)->__toString(); + + $this->assertEquals($chain, $auto); + $this->assertEquals( + ''. + '', $auto); + } + public function testCanRepopulateGroupedCheckboxes() { - $this->markTestSkipped('This is failing you guys'); + $this->former->framework('Nude'); + $this->former->populate(array('foo' => array(0 => 0, 1 => 1))); + + $chain = $this->former->checkboxes('foo', '')->grouped()->checkboxes('Value 01', 'Value 02', 'Value 03')->__toString(); + $auto = $this->former->checkboxes('foo[]', '')->checkboxes('Value 01', 'Value 02', 'Value 03')->__toString(); + + $matcher = + ''. + ''. + ''; + + $this->assertEquals($matcher, $chain); + $this->assertEquals($matcher, $auto); + } + public function testCanRepopulateGroupedCheckboxesFromPost() + { $this->former->framework('Nude'); - $this->former->populate(array('foo' => array('foo_0'))); - $checkboxes = $this->former->checkboxes('foo', '')->grouped()->checkboxes('Value 01', 'Value 02')->__toString(); - $this->assertEquals( + $this->request->shouldReceive('input')->with('_token', '', true)->andReturn(''); + $this->request->shouldReceive('input')->with('foo', '', true)->andReturn( + array(0 => 0, 1 => 1) + ); + + $chain = $this->former->checkboxes('foo', '')->grouped()->checkboxes('Value 01', 'Value 02', 'Value 03')->__toString(); + $auto = $this->former->checkboxes('foo[]', '')->checkboxes('Value 01', 'Value 02', 'Value 03')->__toString(); + + $matcher = ''. '', $checkboxes); + 'Value 02'. + ''. + ''; + + $this->assertEquals($matcher, $chain); + $this->assertEquals($matcher, $auto); + } + + public function testCanRepopulateCustomizedGroupedCheckboxesFromPost() + { + $this->former->framework('Nude'); + + $checkboxes = array( + 'Value 01' => array( + 'id' => 'value[foo_id]', + 'name' => 'value[foo_name]', + 'value' => 'foo_value', + ), + 'Value 02' => array( + 'id' => 'value[bar_id]', + 'name' => 'value[bar_name]', + 'value' => 'bar_value', + ), + ); + + $this->request->shouldReceive('input')->with('_token', '', true)->andReturn(''); + $this->request->shouldReceive('input')->with('value', '', true)->andReturn( + array('foo_name' => 'foo_value') + ); + $auto = $this->former->checkboxes('value[]', '')->checkboxes($checkboxes)->__toString(); + $chain = $this->former->checkboxes('value', '')->grouped()->checkboxes($checkboxes)->__toString(); + + $this->assertEquals($chain, $auto); + $this->assertEquals( + ''. + '', $auto); } public function testCanCustomizeTheUncheckedValue() From 1495e6dd760f99bef422bb9e86154d1ef01e8965 Mon Sep 17 00:00:00 2001 From: Ben Claar Date: Sat, 12 Apr 2014 12:05:48 -0500 Subject: [PATCH 12/32] Fix and test multiple select repopulation. --- src/Former/Form/Fields/Select.php | 4 ++-- tests/Fields/SelectTest.php | 40 ++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 3 deletions(-) diff --git a/src/Former/Form/Fields/Select.php b/src/Former/Form/Fields/Select.php index f4b0e95d..580d7404 100644 --- a/src/Former/Form/Fields/Select.php +++ b/src/Former/Form/Fields/Select.php @@ -62,8 +62,8 @@ public function __construct(Container $app, $type, $name, $label, $options, $sel parent::__construct($app, $type, $name, $label, $selected, $attributes); - // Multiple models population - if (is_array($this->value) and !empty($this->value) and is_string($this->value[key($this->value)])) { + // Nested models population + if (str_contains($this->name, '.') and is_array($this->value) and !empty($this->value) and is_string($this->value[key($this->value)])) { $this->fromQuery($this->value); $this->value = $selected ?: null; } diff --git a/tests/Fields/SelectTest.php b/tests/Fields/SelectTest.php index a3c7732f..ef9449b6 100644 --- a/tests/Fields/SelectTest.php +++ b/tests/Fields/SelectTest.php @@ -267,6 +267,28 @@ public function testCanPopulateMultipleSelects() $this->assertEquals($matcher, $select); } + public function testCanRepopulateMultipleSelectsFromPost() + { + $options = array( + 'foo' => 'foo_name', + 'bar' => 'bar_name', + 'baz' => 'baz_name', + ); + + $this->request->shouldReceive('input')->with('_token', '', true)->andReturn('foobar'); + $this->request->shouldReceive('input')->with('test', '', true)->andReturn(array('foo', 'bar')); + + $select = $this->former->multiselect('test')->options($options)->render(); + $matcher = + ''; + + $this->assertEquals($matcher, $select); + } + public function testCanCreateRangeSelects() { $select = $this->former->select('foo')->range(1, 10); @@ -347,7 +369,7 @@ public function testOptionsSelectActsTheSameAsSelect() $this->assertContains($matcher, $select); } - public function testCanRepopulateArrayNotation() + public function testCanRepopulateFromPostArrayNotation() { $options = array('foo', 'bar'); $this->request->shouldReceive('input')->with('_token', '', true)->andReturn('foobar'); @@ -359,6 +381,22 @@ public function testCanRepopulateArrayNotation() $this->assertEquals($matcher, $select->render()); } + public function testCanRepopulateFromPostStringIndexedArrayNotation() + { + $options = array('foo' => 'foo_name', 'bar' => 'bar_name'); + $this->request->shouldReceive('input')->with('_token', '', true)->andReturn('foobar'); + $this->request->shouldReceive('input')->with('foo', '', true)->andReturn(array('foo', 'bar')); + + $select = $this->former->select('foo[]')->options($options); + $matcher = + ''; + + $this->assertEquals($matcher, $select->render()); + } + public function testMultiselectRepopulationDoesntCreateOptions() { $options = array(1 => 'foo', 2 => 'bar'); From 4da97bd512778dd066e5125c64c55afac656eea0 Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Tue, 15 Apr 2014 14:58:18 -0700 Subject: [PATCH 13/32] coding style improvements - fixed brace location as per PSR-2, fixed indent --- src/Former/Framework/ZurbFoundation4.php | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Former/Framework/ZurbFoundation4.php b/src/Former/Framework/ZurbFoundation4.php index 70ea4cff..f4c8f100 100644 --- a/src/Former/Framework/ZurbFoundation4.php +++ b/src/Former/Framework/ZurbFoundation4.php @@ -158,11 +158,10 @@ public function getActionClasses() public function createHelp($text, $attributes = null) { - if ($attributes == null) - { + if (is_null($attributes)) { $attributes = $this->getFrameworkOption('error_classes'); - } - return Element::create('span', $text, $attributes); + } + return Element::create('span', $text, $attributes); } /** From b911292aa2e2f7dc9800d464532cb9ba3a2afdd1 Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Tue, 15 Apr 2014 15:14:40 -0700 Subject: [PATCH 14/32] added foundation option error_classes to ZurbFoundation to allow customizing alert style; default to alert-box alert warning --- src/Former/Framework/ZurbFoundation.php | 6 +++++- src/config/ZurbFoundation.php | 4 ++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/Former/Framework/ZurbFoundation.php b/src/Former/Framework/ZurbFoundation.php index 49bcb6bc..973ae0f8 100644 --- a/src/Former/Framework/ZurbFoundation.php +++ b/src/Former/Framework/ZurbFoundation.php @@ -154,11 +154,15 @@ public function getActionClasses() //////////////////////////// RENDER BLOCKS ///////////////////////// //////////////////////////////////////////////////////////////////// - public function createHelp($text, $attributes = array()) + public function createHelp($text, $attributes = null) { + if (is_null($attributes)) { + $attributes = $this->getFrameworkOption('error_classes'); + } return Element::create('span', $text, $attributes); } + /** * Render a disabled field * diff --git a/src/config/ZurbFoundation.php b/src/config/ZurbFoundation.php index 88a141c4..1bb30891 100644 --- a/src/config/ZurbFoundation.php +++ b/src/config/ZurbFoundation.php @@ -27,4 +27,8 @@ 'prefix' => 'fi', ), + // CSS for inline validation errors + // should work for Zurb 2 and 3 + 'error_classes' => array ( 'class' => 'alert-box alert warning' ) + ); From ba78a7f870b53268af3eb9cacb95ad0774ef100c Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Tue, 15 Apr 2014 15:33:46 -0700 Subject: [PATCH 15/32] fixed Zurb tests to recognize switch of tag from small to span --- tests/Framework/ZurbFramework4Test.php | 2 +- tests/Framework/ZurbFrameworkTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/Framework/ZurbFramework4Test.php b/tests/Framework/ZurbFramework4Test.php index b2818e0e..684fbb0a 100644 --- a/tests/Framework/ZurbFramework4Test.php +++ b/tests/Framework/ZurbFramework4Test.php @@ -50,7 +50,7 @@ public function testCanSetAnErrorStateOnAField() public function testCanAppendHelpTexts() { $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); - $matcher = array('tag' => 'small', 'content' => 'Bar'); + $matcher = array('tag' => 'span', 'content' => 'Bar'); $this->assertLabel($input); $this->assertHTML($this->matchField(), $input); diff --git a/tests/Framework/ZurbFrameworkTest.php b/tests/Framework/ZurbFrameworkTest.php index d90eb77f..c166da01 100644 --- a/tests/Framework/ZurbFrameworkTest.php +++ b/tests/Framework/ZurbFrameworkTest.php @@ -49,7 +49,7 @@ public function testCanSetAnErrorStateOnAField() public function testCanAppendHelpTexts() { $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); - $matcher = array('tag' => 'small', 'content' => 'Bar'); + $matcher = array('tag' => 'span', 'content' => 'Bar'); $this->assertLabel($input); $this->assertHTML($this->matchField(), $input); From 04fa5ff5f97efe1d0397a64daaa2aefcf403cbac Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Tue, 15 Apr 2014 16:33:25 -0700 Subject: [PATCH 16/32] added tests for Zurb and Zurb4 for error_classes fountation option --- src/Former/Framework/ZurbFoundation.php | 3 +-- src/Former/Framework/ZurbFoundation4.php | 2 +- src/config/ZurbFoundation.php | 2 +- tests/Framework/ZurbFramework4Test.php | 12 ++++++++++++ tests/Framework/ZurbFrameworkTest.php | 10 ++++++++++ tests/TestCases/ContainerTestCase.php | 2 ++ 6 files changed, 27 insertions(+), 4 deletions(-) diff --git a/src/Former/Framework/ZurbFoundation.php b/src/Former/Framework/ZurbFoundation.php index 973ae0f8..24ac2928 100644 --- a/src/Former/Framework/ZurbFoundation.php +++ b/src/Former/Framework/ZurbFoundation.php @@ -156,13 +156,12 @@ public function getActionClasses() public function createHelp($text, $attributes = null) { - if (is_null($attributes)) { + if (is_null($attributes) or empty($attributes)) { $attributes = $this->getFrameworkOption('error_classes'); } return Element::create('span', $text, $attributes); } - /** * Render a disabled field * diff --git a/src/Former/Framework/ZurbFoundation4.php b/src/Former/Framework/ZurbFoundation4.php index f4c8f100..420a11a2 100644 --- a/src/Former/Framework/ZurbFoundation4.php +++ b/src/Former/Framework/ZurbFoundation4.php @@ -158,7 +158,7 @@ public function getActionClasses() public function createHelp($text, $attributes = null) { - if (is_null($attributes)) { + if (is_null($attributes) or empty($attributes)) { $attributes = $this->getFrameworkOption('error_classes'); } return Element::create('span', $text, $attributes); diff --git a/src/config/ZurbFoundation.php b/src/config/ZurbFoundation.php index 1bb30891..41d04e18 100644 --- a/src/config/ZurbFoundation.php +++ b/src/config/ZurbFoundation.php @@ -29,6 +29,6 @@ // CSS for inline validation errors // should work for Zurb 2 and 3 - 'error_classes' => array ( 'class' => 'alert-box alert warning' ) + 'error_classes' => array ( 'class' => 'alert-box alert error' ) ); diff --git a/tests/Framework/ZurbFramework4Test.php b/tests/Framework/ZurbFramework4Test.php index 684fbb0a..20ddc4e7 100644 --- a/tests/Framework/ZurbFramework4Test.php +++ b/tests/Framework/ZurbFramework4Test.php @@ -1,4 +1,6 @@ assertEquals($match, $field); } + public function testHelpTextHasCorrectClasses() + { + + $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); + $matcher = array('tag' => 'span', 'attributes' => array( 'class' => 'alert-box radius warning' ), 'content' => 'Bar'); + $this->assertHTML($matcher, $input); + + } + + } diff --git a/tests/Framework/ZurbFrameworkTest.php b/tests/Framework/ZurbFrameworkTest.php index c166da01..118eddee 100644 --- a/tests/Framework/ZurbFrameworkTest.php +++ b/tests/Framework/ZurbFrameworkTest.php @@ -92,4 +92,14 @@ public function testHorizontalFormInputField() $this->assertEquals($match, $field); } + public function testHelpTextHasCorrectClasses() + { + + $input = $this->former->text('foo')->inlineHelp('bar')->__toString(); + $matcher = array('tag' => 'span', 'attributes' => array( 'class' => 'alert-box alert error' ), 'content' => 'Bar'); + $this->assertHTML($matcher, $input); + + } + + } diff --git a/tests/TestCases/ContainerTestCase.php b/tests/TestCases/ContainerTestCase.php index 9dbf2c85..33a0a36a 100644 --- a/tests/TestCases/ContainerTestCase.php +++ b/tests/TestCases/ContainerTestCase.php @@ -139,12 +139,14 @@ protected function mockConfig(array $options = array()) 'ZurbFoundation.labelWidths' => array('large' => 2, 'small' => 4), 'ZurbFoundation.viewports' => array('large' => '', 'medium' => null, 'small' => 'mobile-', 'mini' => null), 'ZurbFoundation.wrappedLabelClasses' => array('right', 'inline'), + 'ZurbFoundation.error_classes' => array('class' => 'alert-box alert error'), 'ZurbFoundation4.icon.prefix' => 'foundicon', 'ZurbFoundation4.icon.set' => 'general', 'ZurbFoundation4.icon.tag' => 'i', 'ZurbFoundation4.labelWidths' => array('small' => 3), 'ZurbFoundation4.viewports' => array('large' => 'large', 'medium' => null, 'small' => 'small', 'mini' => null), 'ZurbFoundation4.wrappedLabelClasses' => array('right','inline'), + 'ZurbFoundation4.error_classes' => array('class' => 'alert-box radius warning'), ), $options); return $this->mock('config', 'Config', function ($mock) use ($options) { From 30084cdf8f1ecaed014f023714966ce53aafa23f Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Wed, 16 Apr 2014 08:10:26 -0700 Subject: [PATCH 17/32] code style changes - removed spaces around array() --- src/config/ZurbFoundation.php | 2 +- src/config/ZurbFoundation4.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/config/ZurbFoundation.php b/src/config/ZurbFoundation.php index 41d04e18..f16e2a46 100644 --- a/src/config/ZurbFoundation.php +++ b/src/config/ZurbFoundation.php @@ -29,6 +29,6 @@ // CSS for inline validation errors // should work for Zurb 2 and 3 - 'error_classes' => array ( 'class' => 'alert-box alert error' ) + 'error_classes' => array('class' => 'alert-box alert error') ); diff --git a/src/config/ZurbFoundation4.php b/src/config/ZurbFoundation4.php index a1eb050c..8ebfd10e 100644 --- a/src/config/ZurbFoundation4.php +++ b/src/config/ZurbFoundation4.php @@ -29,6 +29,6 @@ ), // CSS for inline validation errors - 'error_classes' => array ( 'class' => 'alert-box radius warning' ) + 'error_classes' => array('class' => 'alert-box radius warning') ); From 0a9ce8b77e6a106c3fe4b773437d5d1a407538d1 Mon Sep 17 00:00:00 2001 From: Adam Feuer Date: Wed, 16 Apr 2014 08:11:34 -0700 Subject: [PATCH 18/32] removed mistakenly added unused 'use mockery' line --- tests/Framework/ZurbFramework4Test.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Framework/ZurbFramework4Test.php b/tests/Framework/ZurbFramework4Test.php index 20ddc4e7..61c352d8 100644 --- a/tests/Framework/ZurbFramework4Test.php +++ b/tests/Framework/ZurbFramework4Test.php @@ -1,5 +1,4 @@ Date: Wed, 23 Apr 2014 13:23:30 +0200 Subject: [PATCH 19/32] Fixed bug where minlength attribute is not a valid attribute, used pattern instead --- src/Former/LiveValidation.php | 29 +++++++++++++++++++++++++---- tests/LiveValidationTest.php | 8 ++++---- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/src/Former/LiveValidation.php b/src/Former/LiveValidation.php index f59f9f71..6ffce92c 100644 --- a/src/Former/LiveValidation.php +++ b/src/Former/LiveValidation.php @@ -212,8 +212,7 @@ public function between($between) { list($min, $max) = $between; - $this->setMin($min); - $this->setMax($max); + $this->setBetween($min, $max); } /** @@ -315,8 +314,30 @@ private function setMax($max) */ private function setMin($min) { - $attribute = $this->field->isOfType('number') ? 'min' : 'minlength'; + if ($this->field->isOfType('number') == 'min') { + $this->field->min($min); + } else { + $this->field->pattern(".{" . $min . ",}"); + } + } + + /** + * Set a minimum and maximum value to a field + * + * @param $min + * @param $max + */ + public function setBetween($min, $max) + { + if ($this->field->isOfType('number') == 'min') { + // min, max values for generation of the pattern + $this->field->min($min); + $this->field->max($max); + } else { + $this->field->pattern('.{' . $min . ',' . $max . '}'); - $this->field->$attribute($min); + // still let the browser limit text input after reaching the max + $this->field->maxlength($max); + } } } diff --git a/tests/LiveValidationTest.php b/tests/LiveValidationTest.php index 4f713816..c490d7d0 100644 --- a/tests/LiveValidationTest.php +++ b/tests/LiveValidationTest.php @@ -186,7 +186,7 @@ public function testCanSetMinToText() $this->former->withRules(array('foo' => 'min:42')); $input = $this->former->text('foo')->__toString(); - $matcher = $this->matchField(array('minlength' => '42')); + $matcher = $this->matchField(array('pattern' => '.{42,}')); $this->assertHTML($matcher, $input); $this->assertControlGroup($input); @@ -197,7 +197,7 @@ public function testCanSetMinToTextAsArray() $this->former->withRules(array('foo' => array('min:42'))); $input = $this->former->text('foo')->__toString(); - $matcher = $this->matchField(array('minlength' => '42')); + $matcher = $this->matchField(array('pattern' => '.{42,}')); $this->assertHTML($matcher, $input); $this->assertControlGroup($input); @@ -421,7 +421,7 @@ public function testCanSetBoundariesToText() $this->former->withRules(array('foo' => 'between:1,10')); $input = $this->former->text('foo')->__toString(); - $matcher = $this->matchField(array('minlength' => '1', 'maxlength' => '10')); + $matcher = $this->matchField(array('pattern' => '.{1,10}', 'maxlength' => '10')); $this->assertControlGroup($input); $this->assertHTML($matcher, $input); @@ -432,7 +432,7 @@ public function testCanSetBoundariesToTextAsArray() $this->former->withRules(array('foo' => array('between:1,10'))); $input = $this->former->text('foo')->__toString(); - $matcher = $this->matchField(array('minlength' => '1', 'maxlength' => '10')); + $matcher = $this->matchField(array('pattern' => '.{1,10}', 'maxlength' => '10')); $this->assertControlGroup($input); $this->assertHTML($matcher, $input); From 7879565fbce777439640a6174b1811594b9c912a Mon Sep 17 00:00:00 2001 From: Luuk Holleman Date: Wed, 23 Apr 2014 13:45:30 +0200 Subject: [PATCH 20/32] Fixed indentation --- src/Former/LiveValidation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Former/LiveValidation.php b/src/Former/LiveValidation.php index 6ffce92c..2feb341a 100644 --- a/src/Former/LiveValidation.php +++ b/src/Former/LiveValidation.php @@ -212,7 +212,7 @@ public function between($between) { list($min, $max) = $between; - $this->setBetween($min, $max); + $this->setBetween($min, $max); } /** From 6f8fc63841bae8a0b827e6e0ae6439bb1ee59030 Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sat, 31 May 2014 20:21:56 -0400 Subject: [PATCH 21/32] added optional $step param to range method --- src/Former/Form/Fields/Select.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Former/Form/Fields/Select.php b/src/Former/Form/Fields/Select.php index 580d7404..4077b46b 100644 --- a/src/Former/Form/Fields/Select.php +++ b/src/Former/Form/Fields/Select.php @@ -197,8 +197,9 @@ public function options($_options, $selected = null, $valuesAsKeys = false) * * @param integer $from * @param integer $to + * @param integer $step */ - public function range($from, $to) + public function range($from, $to, $step = 1) { $range = range($from, $to); $this->options($range, null, true); From e2c9ca95f8638f21d833a5ea2517f240378e379d Mon Sep 17 00:00:00 2001 From: Andrew Morgan Date: Sat, 31 May 2014 22:33:43 -0400 Subject: [PATCH 22/32] added optional $step param to range method --- src/Former/Form/Fields/Select.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Former/Form/Fields/Select.php b/src/Former/Form/Fields/Select.php index 4077b46b..df370e86 100644 --- a/src/Former/Form/Fields/Select.php +++ b/src/Former/Form/Fields/Select.php @@ -201,7 +201,7 @@ public function options($_options, $selected = null, $valuesAsKeys = false) */ public function range($from, $to, $step = 1) { - $range = range($from, $to); + $range = range($from, $to, $step); $this->options($range, null, true); return $this; From d35a5f665944b11e59db2c90e5749fdf9d672fb3 Mon Sep 17 00:00:00 2001 From: James Eagle Date: Thu, 12 Jun 2014 10:51:00 +0100 Subject: [PATCH 23/32] Adding some missing semi colons. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ed336ec9..6d74881f 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ Former::horizontal_open() ->id('MyForm') ->secure() ->rules(['name' => 'required']) - ->method('GET') + ->method('GET'); Former::xlarge_text('name') ->class('myclass') @@ -33,9 +33,9 @@ Former::horizontal_open() Former::actions() ->large_primary_submit('Submit') - ->large_inverse_reset('Reset') + ->large_inverse_reset('Reset'); -Former::close() +Former::close(); ``` Every time you call a method that doesn't actually exist, Former assumes you're trying to set an attribute and creates it magically. That's why you can do in the above example `->rows(10)` ; in case you want to set attributes that contain dashes, just replace them by underscores : `->data_foo('bar')` equals `data-foo="bar"`. From 12e1a9eeb6991b9298e06addb991794f59dac059 Mon Sep 17 00:00:00 2001 From: lowerends Date: Fri, 13 Jun 2014 16:01:26 +0200 Subject: [PATCH 24/32] Fix for #299, including test. --- src/Former/Former.php | 5 +++++ src/Former/Populator.php | 5 +++++ tests/Fields/InputTest.php | 15 +++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/src/Former/Former.php b/src/Former/Former.php index 3726322a..b2b54a0e 100644 --- a/src/Former/Former.php +++ b/src/Former/Former.php @@ -417,6 +417,11 @@ public function getErrors($name = null) // Get name and translate array notation if (!$name and $this->app['former.field']) { $name = $this->app['former.field']->getName(); + + // Always return empty string for anonymous fields (i.e. fields with no name/id) + if (!$name) { + return ''; + } } if ($this->errors and $name) { diff --git a/src/Former/Populator.php b/src/Former/Populator.php index 09c0c7ba..e92e64c1 100644 --- a/src/Former/Populator.php +++ b/src/Former/Populator.php @@ -35,6 +35,11 @@ public function __construct($items = array()) */ public function get($field, $fallback = null) { + // Anonymous fields should not return any value + if ($field == null) { + return null; + } + // Plain array if (is_array($this->items) and !str_contains($field, '[')) { return parent::get($field, $fallback); diff --git a/tests/Fields/InputTest.php b/tests/Fields/InputTest.php index af8d64cf..9999a9aa 100644 --- a/tests/Fields/InputTest.php +++ b/tests/Fields/InputTest.php @@ -126,6 +126,21 @@ public function testCanCreateWithErrors() $this->assertEquals($matcher, $required); } + public function testAnonymousFieldHasNoErrors() + { + $this->former->withErrors($this->validator); + + $required = $this->former->text()->__toString(); + $matcher = + '
'. + '
'. + ''. + '
'. + '
'; + + $this->assertEquals($matcher, $required); + } + public function testCanDisableErrors() { $this->mockConfig(array('error_messages' => false)); From 93faa0fad9da93489615b58b0fb16f7f20fcc833 Mon Sep 17 00:00:00 2001 From: Ben Rogers Date: Thu, 19 Jun 2014 21:02:25 -0700 Subject: [PATCH 25/32] Block Help for Bootstrap3 --- src/Former/Form/Group.php | 2 +- src/Former/Framework/TwitterBootstrap3.php | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/Former/Form/Group.php b/src/Former/Form/Group.php index 485b7df7..74dc5385 100644 --- a/src/Former/Form/Group.php +++ b/src/Former/Form/Group.php @@ -290,7 +290,7 @@ public function inlineHelp($help, $attributes = array()) public function blockHelp($help, $attributes = array()) { // Reserved method - if ($this->app['former.framework']->isnt('TwitterBootstrap')) { + if ($this->app['former.framework']->isnt('TwitterBootstrap') && $this->app['former.framework']->isnt('TwitterBootstrap3')) { throw new BadMethodCallException('This method is only available on the Bootstrap framework'); } diff --git a/src/Former/Framework/TwitterBootstrap3.php b/src/Former/Framework/TwitterBootstrap3.php index 49e56e67..18963eab 100644 --- a/src/Former/Framework/TwitterBootstrap3.php +++ b/src/Former/Framework/TwitterBootstrap3.php @@ -306,6 +306,19 @@ public function createHelp($text, $attributes = array()) return Element::create('span', $text, $attributes)->addClass('help-block'); } + /** + * Render an help text + * + * @param string $text + * @param array $attributes + * + * @return string + */ + public function createBlockHelp($text, $attributes = array()) + { + return Element::create('p', $text, $attributes)->addClass('help-block'); + } + /** * Render a disabled field * From 320531d0fdd4c9bcbfeb816ed5327161bb3a8317 Mon Sep 17 00:00:00 2001 From: Ben Claar Date: Thu, 3 Jul 2014 11:51:59 -0500 Subject: [PATCH 26/32] Add additional tests for radios, cleanup radio tests a bit. --- tests/Fields/RadioTest.php | 40 +++++++++++++++++++++++++++++---- tests/TestCases/FormerTests.php | 14 ++++++++++++ 2 files changed, 50 insertions(+), 4 deletions(-) diff --git a/tests/Fields/RadioTest.php b/tests/Fields/RadioTest.php index 09965e91..7333c5e4 100644 --- a/tests/Fields/RadioTest.php +++ b/tests/Fields/RadioTest.php @@ -139,10 +139,10 @@ public function testMultipleArray() public function testMultipleCustom() { - $radios = $this->former->radios('foo')->radios($this->checkables)->__toString(); + $radios = $this->former->radios('foo')->radios($this->radioCheckables)->__toString(); $matcher = $this->controlGroup( ''. '