Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Update repository

  • Loading branch information...
commit c722433a3bb48e11463cd2eb29e9f30ee1373c8f 1 parent 441ebb5
@Anahkiasen Anahkiasen authored
Showing with 2,878 additions and 3,818 deletions.
  1. +2 −1  .gitignore
  2. +14 −0 CONTRIBUTING.md
  3. +35 −0 composer.json
  4. +459 −0 composer.lock
  5. +39 −19 src/Former/Dispatch.php
  6. +20 −19 src/Former/Facades/Agnostic.php
  7. +22 −41 src/Former/Facades/FormerBuilder.php
  8. +3 −5 src/Former/Facades/Illuminate.php
  9. +5 −13 src/Former/Facades/LaravelThree.php
  10. +3 −6 src/Former/Facades/Legacy/Config.php
  11. +8 −4 src/Former/Facades/Legacy/Redirector.php
  12. +2 −4 src/Former/Facades/Legacy/Session.php
  13. +2 −4 src/Former/Facades/Legacy/Translator.php
  14. +38 −43 src/Former/Form/Actions.php
  15. +2 −4 src/Former/Form/CheckableGroup.php
  16. +36 −13 src/Former/Form/Elements.php
  17. +52 −35 src/Former/Form/Fields/Button.php
  18. +4 −5 src/Former/Form/Fields/Checkbox.php
  19. +26 −20 src/Former/Form/Fields/File.php
  20. +9 −8 src/Former/Form/Fields/Hidden.php
  21. +33 −12 src/Former/Form/Fields/Input.php
  22. +3 −5 src/Former/Form/Fields/Radio.php
  23. +70 −38 src/Former/Form/Fields/Select.php
  24. +12 −10 src/Former/Form/Fields/Textarea.php
  25. +7 −7 src/Former/Form/Fields/Uneditable.php
  26. +71 −26 src/Former/Form/Form.php
  27. +67 −59 src/Former/Form/Group.php
  28. +32 −14 src/Former/Former.php
  29. +3 −6 src/Former/FormerServiceProvider.php
  30. +23 −24 src/Former/Framework/Nude.php
  31. +36 −54 src/Former/Framework/TwitterBootstrap.php
  32. +22 −22 src/Former/Framework/ZurbFoundation.php
  33. +25 −43 src/Former/Helpers.php
  34. +3 −5 src/Former/Interfaces/FieldInterface.php
  35. +12 −11 src/Former/Interfaces/FrameworkInterface.php
  36. +4 −6 src/Former/LiveValidation.php
  37. +5 −7 src/Former/Populator.php
  38. +32 −23 src/Former/Traits/Checkable.php
  39. +42 −36 src/Former/Traits/Field.php
  40. +46 −7 src/Former/Traits/FormerObject.php
  41. +16 −36 src/Former/Traits/Framework.php
  42. +4 −0 src/config/config.php
  43. +8 −16 tests/ActionsTest.php
  44. +5 −34 tests/Fields/ButtonTest.php
  45. +16 −15 tests/Fields/CheckboxTest.php
  46. +5 −2 tests/Fields/FileTest.php
  47. +84 −44 tests/Fields/InputTest.php
  48. +17 −7 tests/Fields/RadioTest.php
  49. +15 −3 tests/Fields/SelectTest.php
  50. +2 −1  tests/Fields/TextareaTest.php
  51. +12 −3 tests/FormTest.php
  52. +2 −2 tests/FormerTest.php
  53. +2 −2 tests/Framework/ZurbFrameworkTest.php
  54. +3 −3 tests/GroupTest.php
  55. +1 −1  tests/LiveValidationTest.php
  56. +6 −8 tests/_illuminate.php
  57. +75 −9 tests/_start.php
  58. +48 −56 vendor/anahkiasen/html-object/README.md
  59. +4 −4 vendor/anahkiasen/html-object/src/HtmlObject/Element.php
  60. +8 −1 vendor/anahkiasen/html-object/src/HtmlObject/Image.php
  61. +7 −0 vendor/anahkiasen/html-object/src/HtmlObject/Input.php
  62. +8 −1 vendor/anahkiasen/html-object/src/HtmlObject/Link.php
  63. +0 −16 vendor/anahkiasen/html-object/src/HtmlObject/Lists.php
  64. +3 −3 vendor/anahkiasen/html-object/src/HtmlObject/Traits/Helpers.php
  65. +122 −71 vendor/anahkiasen/html-object/src/HtmlObject/Traits/Tag.php
  66. +98 −17 vendor/anahkiasen/html-object/src/HtmlObject/Traits/TreeObject.php
  67. +4 −2 vendor/anahkiasen/html-object/tests/InputTest.php
  68. +51 −0 vendor/anahkiasen/html-object/tests/TagTest.php
  69. +46 −0 vendor/anahkiasen/html-object/tests/TreeObjectTest.php
  70. +1 −1  vendor/anahkiasen/underscore-php/.travis.yml
  71. +5 −5 vendor/anahkiasen/underscore-php/composer.lock
  72. +0 −22 vendor/anahkiasen/underscore-php/phpunit.xml.dist
  73. +30 −36 vendor/anahkiasen/underscore-php/src/Underscore/Dispatch.php
  74. +32 −16 vendor/anahkiasen/underscore-php/src/Underscore/Method.php
  75. +5 −2 vendor/anahkiasen/underscore-php/src/Underscore/Methods/ArraysMethods.php
  76. +6 −5 vendor/anahkiasen/underscore-php/src/Underscore/Methods/CollectionMethods.php
  77. +12 −55 vendor/anahkiasen/underscore-php/src/Underscore/Methods/StringMethods.php
  78. +59 −21 vendor/anahkiasen/underscore-php/src/Underscore/Parse.php
  79. +14 −14 vendor/anahkiasen/underscore-php/src/Underscore/Traits/Repository.php
  80. +1 −1  vendor/anahkiasen/underscore-php/src/Underscore/Types/Number.php
  81. +5 −6 vendor/anahkiasen/underscore-php/src/Underscore/Underscore.php
  82. +10 −2 vendor/anahkiasen/underscore-php/tests/Dispatch.test.php
  83. +7 −0 vendor/anahkiasen/underscore-php/tests/Method.test.php
  84. +17 −0 vendor/anahkiasen/underscore-php/tests/Parse.test.php
  85. +8 −0 vendor/anahkiasen/underscore-php/tests/Types/Arrays.test.php
  86. +0 −1  vendor/anahkiasen/underscore-php/tests/Types/Functions.test.php
  87. +5 −1 vendor/anahkiasen/underscore-php/tests/Types/Number.test.php
  88. +22 −0 vendor/anahkiasen/underscore-php/tests/Types/Object.test.php
  89. +1 −1  vendor/anahkiasen/underscore-php/tests/Types/String.test.php
  90. +0 −32 vendor/anahkiasen/underscore-php/tests/Underscore.test.php
  91. +40 −0 vendor/anahkiasen/underscore-php/tests/_start.php
  92. +10 −0 vendor/illuminate/support/Illuminate/Support/Collection.php
  93. +1 −1  vendor/illuminate/support/Illuminate/Support/Facades/App.php
  94. +33 −2 vendor/illuminate/support/Illuminate/Support/Facades/Facade.php
  95. +17 −2 vendor/illuminate/support/Illuminate/Support/Facades/Response.php
  96. +2 −2 vendor/illuminate/support/Illuminate/Support/Fluent.php
  97. +22 −0 vendor/illuminate/support/Illuminate/Support/Str.php
  98. +512 −406 vendor/illuminate/support/Illuminate/Support/helpers.php
  99. +0 −2  vendor/meido/form/.gitignore
  100. +0 −11 vendor/meido/form/.travis.yml
  101. +0 −25 vendor/meido/form/composer.json
  102. +0 −18 vendor/meido/form/phpunit.xml
  103. 0  vendor/meido/form/public/.gitkeep
  104. +0 −92 vendor/meido/form/readme.md
  105. +0 −594 vendor/meido/form/src/Meido/Form/Form.php
  106. +0 −14 vendor/meido/form/src/Meido/Form/FormFacade.php
  107. +0 −47 vendor/meido/form/src/Meido/Form/FormServiceProvider.php
  108. 0  vendor/meido/form/src/config/.gitkeep
  109. 0  vendor/meido/form/src/lang/.gitkeep
  110. 0  vendor/meido/form/src/migrations/.gitkeep
  111. 0  vendor/meido/form/src/views/.gitkeep
  112. 0  vendor/meido/form/tests/.gitkeep
  113. +0 −442 vendor/meido/form/tests/FormTest.php
  114. +0 −2  vendor/meido/html/.gitignore
  115. +0 −11 vendor/meido/html/.travis.yml
  116. +0 −24 vendor/meido/html/composer.json
  117. +0 −18 vendor/meido/html/phpunit.xml
  118. 0  vendor/meido/html/public/.gitkeep
  119. +0 −96 vendor/meido/html/readme.md
  120. +0 −446 vendor/meido/html/src/Meido/HTML/HTML.php
  121. +0 −14 vendor/meido/html/src/Meido/HTML/HTMLFacade.php
  122. +0 −48 vendor/meido/html/src/Meido/HTML/HTMLServiceProvider.php
  123. 0  vendor/meido/html/src/config/.gitkeep
  124. 0  vendor/meido/html/src/lang/.gitkeep
  125. 0  vendor/meido/html/src/migrations/.gitkeep
  126. 0  vendor/meido/html/src/views/.gitkeep
  127. 0  vendor/meido/html/tests/.gitkeep
  128. +0 −264 vendor/meido/html/tests/HTMLTest.php
View
3  .gitignore
@@ -1,2 +1,3 @@
!phpunit.xml
-tests/logs
+tests/logs
+vendor
View
14 CONTRIBUTING.md
@@ -0,0 +1,14 @@
+# Contribution guidelines
+
+Before reporting any issue, please put in the name of your issue a tag specifying the environment you're using Former in :
+
+ [L3] Problem with X
+ [L4] Added X yo Y
+ [Agnostic] etc.
+
+If you have a code suggestion, do a pull request against the `agnostic` branch — not **master**.
+Don't forget to add a test in the `tests` folder :
+- If it's a feature you're adding, add a test proving it works.
+- If it's a bug you're fixing, write a bug proving it doesn't occur anymore.
+
+Thanks for you input and thanks for using Former !
View
35 composer.json
@@ -0,0 +1,35 @@
+{
+ "name": "anahkiasen/former",
+ "description": "A powerful form builder for the Laravel framework",
+ "homepage": "http://anahkiasen.github.com/former/",
+ "license": "MIT",
+ "keywords": [
+ "bootstrap",
+ "form",
+ "foundation",
+ "laravel"
+ ],
+ "authors": [
+ {
+ "name": "Maxime Fabre",
+ "email": "ehtnam6@gmail.com"
+ }
+ ],
+ "require": {
+ "anahkiasen/html-object": "dev-master",
+ "anahkiasen/underscore-php": "dev-master",
+ "illuminate/config": "4.0.*@dev",
+ "illuminate/container": "4.0.*@dev",
+ "illuminate/translation" :"4.0.*@dev"
+ },
+ "require-dev": {
+ "mockery/mockery": "dev-master"
+ },
+ "autoload": {
+ "psr-0": {
+ "Former": "src",
+ "Laravel": "src"
+ }
+ },
+ "minimum-stability": "dev"
+}
View
459 composer.lock
@@ -0,0 +1,459 @@
+{
+ "hash": "21e671753147f52142a03614948b6749",
+ "packages": [
+ {
+ "name": "anahkiasen/html-object",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Anahkiasen/html-object.git",
+ "reference": "962217e03cbe1b44b7a571e47cc8ba5c6f435e30"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Anahkiasen/html-object/zipball/962217e03cbe1b44b7a571e47cc8ba5c6f435e30",
+ "reference": "962217e03cbe1b44b7a571e47cc8ba5c6f435e30",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "HtmlObject": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Anahkiasen",
+ "email": "ehtnam6@gmail.com"
+ }
+ ],
+ "description": "A set of classes to create and manipulate HTML objects abstractions",
+ "time": "2013-03-17 23:54:21"
+ },
+ {
+ "name": "anahkiasen/underscore-php",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/Anahkiasen/underscore-php.git",
+ "reference": "cb1398977ecbfc57e26f4becadc07735f4594c0c"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/Anahkiasen/underscore-php/zipball/cb1398977ecbfc57e26f4becadc07735f4594c0c",
+ "reference": "cb1398977ecbfc57e26f4becadc07735f4594c0c",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/support": "4.0.*@dev",
+ "patchwork/utf8": "1.0.*",
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Underscore": "src/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Maxime Fabre",
+ "email": "ehtnam6@gmail.com"
+ }
+ ],
+ "description": "A redacted port of Underscore.js for PHP",
+ "time": "2013-03-15 12:44:17"
+ },
+ {
+ "name": "illuminate/config",
+ "version": "dev-master",
+ "target-dir": "Illuminate/Config",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/illuminate/config.git",
+ "reference": "02bf5cffe092b03ce013d381817ada395568ba1e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/illuminate/config/zipball/02bf5cffe092b03ce013d381817ada395568ba1e",
+ "reference": "02bf5cffe092b03ce013d381817ada395568ba1e",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/filesystem": "4.0.x",
+ "illuminate/support": "4.0.x",
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Illuminate\\Config": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylorotwell@gmail.com"
+ }
+ ],
+ "time": "2013-03-03 01:00:36"
+ },
+ {
+ "name": "illuminate/container",
+ "version": "dev-master",
+ "target-dir": "Illuminate/Container",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/illuminate/container.git",
+ "reference": "73697d956ee9bac52de89fa2235969da45da9a1e"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/illuminate/container/zipball/73697d956ee9bac52de89fa2235969da45da9a1e",
+ "reference": "73697d956ee9bac52de89fa2235969da45da9a1e",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Illuminate\\Container": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylorotwell@gmail.com"
+ }
+ ],
+ "time": "2013-03-03 01:00:36"
+ },
+ {
+ "name": "illuminate/filesystem",
+ "version": "dev-master",
+ "target-dir": "Illuminate/Filesystem",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/illuminate/filesystem.git",
+ "reference": "a3f1aef27e6857690d575bd6f10a670a26e76bc3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/illuminate/filesystem/zipball/a3f1aef27e6857690d575bd6f10a670a26e76bc3",
+ "reference": "a3f1aef27e6857690d575bd6f10a670a26e76bc3",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/support": "4.0.x",
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Illuminate\\Filesystem": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylorotwell@gmail.com"
+ }
+ ],
+ "description": "A filesystem abstraction library.",
+ "time": "2013-03-07 15:18:39"
+ },
+ {
+ "name": "illuminate/support",
+ "version": "dev-master",
+ "target-dir": "Illuminate/Support",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/illuminate/support.git",
+ "reference": "b46d591dd8fe100603777ea84ace34a5314c48a3"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/illuminate/support/zipball/b46d591dd8fe100603777ea84ace34a5314c48a3",
+ "reference": "b46d591dd8fe100603777ea84ace34a5314c48a3",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "require-dev": {
+ "mockery/mockery": "0.7.2",
+ "patchwork/utf8": "1.0.*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Illuminate\\Support": ""
+ },
+ "files": [
+ "Illuminate/Support/helpers.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylorotwell@gmail.com"
+ }
+ ],
+ "description": "Various utilities and support functions.",
+ "time": "2013-03-15 03:55:30"
+ },
+ {
+ "name": "illuminate/translation",
+ "version": "dev-master",
+ "target-dir": "Illuminate/Translation",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/illuminate/translation.git",
+ "reference": "339db6f59babe69367d3cad0a77242668544d5c9"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/illuminate/translation/zipball/339db6f59babe69367d3cad0a77242668544d5c9",
+ "reference": "339db6f59babe69367d3cad0a77242668544d5c9",
+ "shasum": ""
+ },
+ "require": {
+ "illuminate/filesystem": "4.0.x",
+ "illuminate/support": "4.0.x",
+ "php": ">=5.3.0",
+ "symfony/translation": "2.2.*"
+ },
+ "require-dev": {
+ "mockery/mockery": "0.7.2"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "4.0-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Illuminate\\Translation": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "authors": [
+ {
+ "name": "Taylor Otwell",
+ "email": "taylorotwell@gmail.com"
+ }
+ ],
+ "time": "2013-03-17 19:46:31"
+ },
+ {
+ "name": "patchwork/utf8",
+ "version": "v1.0.4",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/nicolas-grekas/Patchwork-UTF8.git",
+ "reference": "v1.0.4"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://github.com/nicolas-grekas/Patchwork-UTF8/archive/v1.0.4.zip",
+ "reference": "v1.0.4",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.0"
+ },
+ "type": "library",
+ "autoload": {
+ "files": [
+ "bootup.utf8.php"
+ ]
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "(Apache-2.0 or GPL-2.0)"
+ ],
+ "authors": [
+ {
+ "name": "Nicolas Grekas",
+ "email": "p@tchwork.com",
+ "role": "Developer"
+ }
+ ],
+ "description": "UTF-8 strings handling for PHP 5.3: portable, performant and extended",
+ "homepage": "https://github.com/nicolas-grekas/Patchwork-UTF8",
+ "keywords": [
+ "i18n",
+ "unicode",
+ "utf-8",
+ "utf8"
+ ],
+ "time": "2012-12-13 08:48:39"
+ },
+ {
+ "name": "symfony/translation",
+ "version": "2.2.x-dev",
+ "target-dir": "Symfony/Component/Translation",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/symfony/Translation.git",
+ "reference": "69548bd41929e873f3a9bdd88c73865b9aba6932"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/symfony/Translation/zipball/69548bd41929e873f3a9bdd88c73865b9aba6932",
+ "reference": "69548bd41929e873f3a9bdd88c73865b9aba6932",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.3"
+ },
+ "require-dev": {
+ "symfony/config": ">=2.0,<2.3-dev",
+ "symfony/yaml": ">=2.2,<3.0"
+ },
+ "suggest": {
+ "symfony/config": "2.2.*",
+ "symfony/yaml": "2.2.*"
+ },
+ "type": "library",
+ "extra": {
+ "branch-alias": {
+ "dev-master": "2.2-dev"
+ }
+ },
+ "autoload": {
+ "psr-0": {
+ "Symfony\\Component\\Translation\\": ""
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "MIT"
+ ],
+ "authors": [
+ {
+ "name": "Fabien Potencier",
+ "email": "fabien@symfony.com"
+ },
+ {
+ "name": "Symfony Community",
+ "homepage": "http://symfony.com/contributors"
+ }
+ ],
+ "description": "Symfony Translation Component",
+ "homepage": "http://symfony.com",
+ "time": "2013-03-15 10:14:31"
+ }
+ ],
+ "packages-dev": [
+ {
+ "name": "mockery/mockery",
+ "version": "dev-master",
+ "source": {
+ "type": "git",
+ "url": "https://github.com/padraic/mockery.git",
+ "reference": "1174be6aed7b3c1e048834f14902ce796b6483c2"
+ },
+ "dist": {
+ "type": "zip",
+ "url": "https://api.github.com/repos/padraic/mockery/zipball/1174be6aed7b3c1e048834f14902ce796b6483c2",
+ "reference": "1174be6aed7b3c1e048834f14902ce796b6483c2",
+ "shasum": ""
+ },
+ "require": {
+ "php": ">=5.3.2"
+ },
+ "require-dev": {
+ "hamcrest/hamcrest": "1.1.0"
+ },
+ "type": "library",
+ "autoload": {
+ "psr-0": {
+ "Mockery": "library/"
+ }
+ },
+ "notification-url": "https://packagist.org/downloads/",
+ "license": [
+ "BSD-3-Clause"
+ ],
+ "authors": [
+ {
+ "name": "Pádraic Brady",
+ "email": "padraic.brady@gmail.com",
+ "homepage": "http://blog.astrumfutura.com"
+ }
+ ],
+ "description": "Mockery is a simple yet flexible PHP mock object framework for use in unit testing with PHPUnit, PHPSpec or any other testing framework. Its core goal is to offer a test double framework with a succint API capable of clearly defining all possible object operations and interactions using a human readable Domain Specific Language (DSL). Designed as a drop in alternative to PHPUnit's phpunit-mock-objects library, Mockery is easy to integrate with PHPUnit and can operate alongside phpunit-mock-objects without the World ending.",
+ "homepage": "http://github.com/padraic/mockery",
+ "keywords": [
+ "BDD",
+ "TDD",
+ "library",
+ "mock",
+ "mock objects",
+ "mockery",
+ "stub",
+ "test",
+ "test double",
+ "testing"
+ ],
+ "time": "2013-03-11 13:49:28"
+ }
+ ],
+ "aliases": [
+
+ ],
+ "minimum-stability": "dev",
+ "stability-flags": {
+ "anahkiasen/html-object": 20,
+ "anahkiasen/underscore-php": 20,
+ "illuminate/config": 20,
+ "illuminate/container": 20,
+ "illuminate/translation": 20,
+ "mockery/mockery": 20
+ },
+ "platform": [
+
+ ],
+ "platform-dev": [
+
+ ]
+}
View
58 src/Former/Dispatch.php
@@ -1,40 +1,47 @@
<?php
-/**
- * Dispatch
- *
- * Dispatch calls to Former to the different
- * form creators like Form, Actions, Elements and others
- */
namespace Former;
-use Underscore\Types\Arrays;
+use Illuminate\Container\Container;
+use Underscore\Methods\ArraysMethods as Arrays;
use Underscore\Types\String;
+/**
+ * Dispatch calls from Former to the different
+ * form creators like Form, Actions, Elements and others
+ */
class Dispatch
{
/**
* Dispatch a call over to Elements
*
+ * @param Container $app The application container
+ * @param string $method The method called
+ * @param array $parameters Its parameters
+ *
* @return string
*/
- public static function toElements($app, $method, $parameters)
+ public static function toElements(Container $app, $method, $parameters)
{
// Disregards if the method isn't an element
- if (!method_exists($elements = new Form\Elements($app), $method)) return false;
+ if (!method_exists($elements = new Form\Elements($app['former'], $app['session']), $method)) return false;
return call_user_func_array(array($elements, $method), $parameters);
}
/**
* Dispatch a call over to Form
*
+ * @param Former $app The application container
+ * @param string $method The method called
+ * @param array $parameters Its parameters
+ *
* @return Form
*/
- public static function toForm($app, $method, $parameters)
+ public static function toForm(Former $former, $method, $parameters)
{
// Disregards if the method doesn't contain 'open'
if (!String::contains($method, 'open')) return false;
- $form = new Form\Form($app);
+ $form = new Form\Form($former, $former->getContainer('url'));
return $form->openForm($method, $parameters);
}
@@ -42,15 +49,19 @@ public static function toForm($app, $method, $parameters)
/**
* Dispatch a call over to Group
*
+ * @param Former $app The application container
+ * @param string $method The method called
+ * @param array $parameters Its parameters
+ *
* @return Group
*/
- public static function toGroup($app, $method, $parameters)
+ public static function toGroup(Former $former, $method, $parameters)
{
// Disregards if the method isn't "group"
if ($method != 'group') return false;
return new Form\Group(
- $app,
- Arrays::get($parameters, 0),
+ $former,
+ Arrays::get($parameters, 0, null),
Arrays::get($parameters, 1, array())
);
}
@@ -58,25 +69,33 @@ public static function toGroup($app, $method, $parameters)
/**
* Dispatch a call over to Actions
*
+ * @param Former $app The application container
+ * @param string $method The method called
+ * @param array $parameters Its parameters
+ *
* @return Actions
*/
- public static function toActions($app, $method, $parameters)
+ public static function toActions(Former $former, $method, $parameters)
{
if ($method != 'actions') return false;
- return new Form\Actions($app, $parameters);
+ return new Form\Actions($former, $parameters);
}
/**
* Dispatch a call over to the Fields
*
+ * @param Former $app The application container
+ * @param string $method The method called
+ * @param array $parameters Its parameters
+ *
* @return Field
*/
- public static function toFields($app, $method, $parameters)
+ public static function toFields(Former $former, $method, $parameters)
{
// Listing parameters
$class = Former::FIELDSPACE.static::getClassFromMethod($method);
$field = new $class(
- $app,
+ $former,
$method,
Arrays::get($parameters, 0),
Arrays::get($parameters, 1),
@@ -97,9 +116,10 @@ public static function toFields($app, $method, $parameters)
* Get the correct class to call according to the created field
*
* @param string $method The field created
+ *
* @return string The correct class
*/
- private static function getClassFromMethod($method)
+ protected static function getClassFromMethod($method)
{
// If the field's name directly match a class, call it
$class = String::from($method)->singular()->title()->obtain();
View
39 src/Former/Facades/Agnostic.php
@@ -1,11 +1,19 @@
<?php
+namespace Former\Facades;
+
+use Illuminate\Config\FileLoader as ConfigLoader;
+use Illuminate\Config\Repository;
+use Illuminate\Container\Container;
+use Illuminate\Cookie\CookieJar;
+use Illuminate\Encryption\Encrypter;
+use Illuminate\Http\Request;
+use Illuminate\Session\CookieStore;
+use Illuminate\Translation\FileLoader;
+use Illuminate\Translation\Translator;
+
/**
- * Agnostic
- *
* Agnostic facade to use Former anywhere
*/
-namespace Former\Facades;
-
class Agnostic extends FormerBuilder
{
/**
@@ -15,7 +23,7 @@ class Agnostic extends FormerBuilder
*/
protected static function getApp()
{
- $app = static::buildContainer();
+ $app = new Container;
// Illuminate -------------------------------------------------- /
@@ -23,39 +31,32 @@ protected static function getApp()
$app->bind('files', 'Illuminate\Filesystem\Filesystem');
$app->bind('url', 'Illuminate\Routing\UrlGenerator');
$app->instance('Illuminate\Container\Container', $app);
-
- $app->bind('session', function($app) {
- $request = new \Illuminate\Http\Request;
- $encrypter = new \Illuminate\Encryption\Encrypter('foobar');
- $cookie = new \Illuminate\Cookie\CookieJar($request, $encrypter, array());
-
- return new \Illuminate\Session\CookieStore($cookie);
- });
+ $app->instance('Illuminate\Encryption\Encrypter', new Encrypter('foobar'));
+ $app->instance('session', 'Illuminate\Session\CookieStore');
$app->bind('Symfony\Component\HttpFoundation\Request', function($app) {
- $request = new \Illuminate\Http\Request;
+ $request = new Request;
$request->setSessionStore($app['session']);
return $request;
});
$app->bind('config', function($app) {
- $fileloader = new \Illuminate\Config\FileLoader($app['files'], 'src/');
+ $fileloader = new ConfigLoader($app['files'], 'src/');
- return new \Illuminate\Config\Repository($fileloader, 'config');
+ return new Repository($fileloader, 'config');
});
$app->bind('loader', function($app) {
- return new \Illuminate\Translation\FileLoader($app['files'], 'src/config');
+ return new FileLoader($app['files'], 'src/config');
});
$app->bind('translator', function($app) {
- return new \Illuminate\Translation\Translator($app['loader'], 'fr', 'en');
+ return new Translator($app['loader'], 'fr', 'en');
});
// Former ------------------------------------------------------ /
- $app = static::buildMeido($app);
$app = static::buildFramework($app);
$app = static::buildFormer($app);
View
63 src/Former/Facades/FormerBuilder.php
@@ -1,23 +1,30 @@
<?php
-/**
- * FormerBuilder
- *
- * Common building blocks to all environments
- */
namespace Former\Facades;
+use Former\Former;
use Illuminate\Container\Container;
+use LaravelBook\Laravel4Powerpack\Form;
+use LaravelBook\Laravel4Powerpack\HTML;
+/**
+ * Common building blocks to all environments
+ */
abstract class FormerBuilder
{
/**
* The Container instance
+ *
* @var Container
*/
protected static $app;
/**
* Static facade
+ *
+ * @param string $method
+ * @param array $parameters
+ *
+ * @return Former
*/
public static function __callStatic($method, $parameters)
{
@@ -30,47 +37,20 @@ public static function __callStatic($method, $parameters)
// Dependency binders -------------------------------------------- /
/**
- * Build Container
- *
- * @return Container
- */
- public static function buildContainer()
- {
- return new Container;
- }
-
- /**
- * Add Meido classes to the app
- *
- * @param Container $app
- * @return Container
- */
- public static function buildMeido($app)
- {
- $app->bind('meido.html', function($app) {
- return new \Meido\HTML\HTML($app['url']);
- });
-
- $app->singleton('meido.form', function($app) {
- return new \Meido\Form\Form($app['url']);
- });
-
- return $app;
- }
-
- /**
* Add Framework to the app
*
- * @param Container $app
+ * @param Container $app
+ * @param string $prefix Where to get config options from
+ *
* @return Container
*/
- public static function buildFramework($app, $prefix = 'config.')
+ public static function buildFramework(Container $app, $prefix = 'config.')
{
$framework = $app['config']->get($prefix.'framework');
$app->bind('\Former\Interfaces\FrameworkInterface', function($app) use ($framework) {
- $framework = '\Former\Framework\\'.$framework;
+ $frameworkClass = '\Former\Framework\\'.$framework;
- return new $framework($app);
+ return new $frameworkClass($app);
});
return $app;
@@ -79,13 +59,14 @@ public static function buildFramework($app, $prefix = 'config.')
/**
* Add Former to the app
*
- * @param Container $app
+ * @param Container $app
+ *
* @return Container
*/
- public static function buildFormer($app)
+ public static function buildFormer(Container $app)
{
$app->singleton('former', function($app) {
- return new \Former\Former(
+ return new Former(
$app,
$app->make('\Former\Populator'),
$app->make('\Former\Interfaces\FrameworkInterface'));
View
8 src/Former/Facades/Illuminate.php
@@ -1,13 +1,11 @@
<?php
-/**
- * Former
- *
- * Former facade for the Laravel framework
- */
namespace Former\Facades;
use Illuminate\Support\Facades\Facade;
+/**
+ * Former facade for the Laravel framework
+ */
class Illuminate extends Facade
{
/**
View
18 src/Former/Facades/LaravelThree.php
@@ -1,13 +1,12 @@
<?php
-/**
- * Legacy
- *
- * Makes Former Laravel 3 compatible
- */
namespace Former\Facades;
+use Illuminate\Container\Container;
use Laravel\Config;
+/**
+ * Makes Former Laravel 3 compatible
+ */
class LaravelThree extends FormerBuilder
{
/**
@@ -17,7 +16,7 @@ class LaravelThree extends FormerBuilder
*/
protected static function getApp()
{
- $app = static::buildContainer();
+ $app = new Container;
// Laravel ----------------------------------------------------- /
@@ -41,13 +40,6 @@ protected static function getApp()
return new Legacy\Translator;
});
- $app->bind('meido.html', function() {
- return new Legacy\Redirector('HTML');
- });
- $app->bind('meido.form', function() {
- return new Legacy\Redirector('Form');
- });
-
// Former ------------------------------------------------------ /
// Load configuration from the new to the old place
View
9 src/Former/Facades/Legacy/Config.php
@@ -1,14 +1,11 @@
<?php
-/**
- * Config
- *
- * Redirect calls to Config instance to Laravel's
- * original static class
- */
namespace Former\Facades\Legacy;
use Laravel\Config as LaravelConfig;
+/**
+ * Redirect calls to Config instance to Laravel's original static class
+ */
class Config extends Redirector
{
/**
View
12 src/Former/Facades/Legacy/Redirector.php
@@ -1,15 +1,14 @@
<?php
+namespace Former\Facades\Legacy;
+
/**
- * Redirector
- *
* Redirects chained calls to static classes
*/
-namespace Former\Facades\Legacy;
-
class Redirector
{
/**
* The name of the class to redirect to
+ *
* @var string
*/
protected $class;
@@ -28,6 +27,7 @@ public function __construct($class = null)
* Set a property on a static class
*
* @param string $key The property
+ *
* @return string Its value
*/
public function __set($key, $value)
@@ -41,6 +41,7 @@ public function __set($key, $value)
* Get a property from a static class
*
* @param string $key The property
+ *
* @return string Its value
*/
public function __get($key)
@@ -52,6 +53,9 @@ public function __get($key)
/**
* Redirect a call to a static class
+ *
+ * @param string $method
+ * @param array $parameters
*/
public function __call($method, $parameters)
{
View
6 src/Former/Facades/Legacy/Session.php
@@ -1,12 +1,10 @@
<?php
+namespace Former\Facades\Legacy;
+
/**
- * Session
- *
* Redirect calls to Session instance to Laravel's
* original static class
*/
-namespace Former\Facades\Legacy;
-
class Session extends Redirector
{
/**
View
6 src/Former/Facades/Legacy/Translator.php
@@ -1,12 +1,10 @@
<?php
+namespace Former\Facades\Legacy;
+
/**
- * Translator
- *
* Redirect calls to the Translator instance to Laravel's
* original Lang class
*/
-namespace Former\Facades\Legacy;
-
class Translator extends Redirector
{
/**
View
81 src/Former/Form/Actions.php
@@ -1,30 +1,30 @@
<?php
-/**
- * Actions
- *
- * Handles the actions part of a form
- * Submit buttons, and such
- */
namespace Former\Form;
+use Former\Former;
use Former\Traits\FormerObject;
-use Underscore\Types\String;
-use Underscore\Types\Arrays;
+use Underscore\Methods\ArraysMethods as Arrays;
+use Underscore\Methods\StringMethods as String;
+/**
+ * Handles the actions part of a form
+ * Submit buttons, and such
+ */
class Actions extends FormerObject
{
/**
* The current environment
+ *
* @var Illuminate\Container
*/
- protected $app;
+ protected $former;
/**
- * The Actions block content
+ * The Actions element
*
* @var string
*/
- protected $content;
+ protected $element = 'div';
////////////////////////////////////////////////////////////////////
/////////////////////////// CORE METHODS ///////////////////////////
@@ -34,12 +34,29 @@ class Actions extends FormerObject
* Constructs a new Actions block
*
* @param Container $app
- * @param array $content The block content
+ * @param array $value The block content
+ */
+ public function __construct(Former $former, $value)
+ {
+ $this->former = $former;
+ $this->value = $value;
+
+ // Add specific actions classes to the actions block
+ $this->addClass($this->former->getFramework()->getActionClasses());
+ }
+
+ /**
+ * Get the content of the Actions block
+ *
+ * @return string
*/
- public function __construct($app, $content)
+ public function getContent()
{
- $this->app = $app;
- $this->content = $content;
+ $content = Arrays::each($this->value, function($content) {
+ return method_exists($content, '__toString') ? (string) $content : $content;
+ });
+
+ return implode(' ', $content);
}
/**
@@ -64,30 +81,6 @@ public function __call($method, $parameters)
return parent::__call($method, $parameters);
}
- /**
- * Render the actions block
- *
- * @return string
- */
- public function __toString()
- {
- // Add specific actions classes to the actions block
- $this->attributes = $this->app['former']->getFramework()->addActionClasses($this->attributes);
-
- // Render passed objects
- $this->content = Arrays::each($this->content, function($content) {
- if (method_exists($content, '__toString')) return $content->__toString();
- else return $content;
- });
-
- // Render block
- $actions = '<div' .$this->app['meido.html']->attributes($this->attributes). '>';
- $actions .= implode(' ', (array) $this->content);
- $actions .= '</div>';
-
- return $actions;
- }
-
////////////////////////////////////////////////////////////////////
////////////////////////////// HELPERS /////////////////////////////
////////////////////////////////////////////////////////////////////
@@ -95,14 +88,16 @@ public function __toString()
/**
* Create a new Button and add it to the actions
*
- * @param string $type The button type
- * @param string $name Its name and label
+ * @param string $type The button type
+ * @param string $name Its name
+ * @param string $link A link to point to
+ * @param array $attributes Its attributes
*
* @return Actions
*/
private function createButtonOfType($type, $name, $link, $attributes)
{
- $this->content[] = $this->app['former']->$type($name, $link, $attributes)->__toString();
+ $this->value[] = $this->former->$type($name, $link, $attributes)->__toString();
return $this;
}
@@ -118,6 +113,6 @@ private function isButton($method)
{
$buttons = array('button', 'submit', 'link', 'reset');
- return String::find($method, $buttons) ? true : false;
+ return (bool) String::find($method, $buttons);
}
}
View
6 src/Former/Form/CheckableGroup.php
@@ -1,11 +1,9 @@
<?php
+namespace Former\Form;
+
/**
- * CheckableGroup
- *
* Manages groups of checkable items
*/
-namespace Former\Form;
-
class CheckableGroup extends Group
{
View
49 src/Former/Form/Elements.php
@@ -1,19 +1,39 @@
<?php
-/**
- * Elements
- *
- * The different parts of a form that are neither fields nor groups
- * not buttons and stuff
- */
namespace Former\Form;
+use Former\Former;
use Former\Helpers;
+use HtmlObject\Element;
+/**
+ * The different parts of a form that are neither fields nor groups
+ * not buttons and stuff
+ */
class Elements
{
- public function __construct($app)
+ /**
+ * The Former instance
+ *
+ * @var Former
+ */
+ protected $former;
+
+ /**
+ * The Session instance
+ *
+ * @var Session
+ */
+ protected $session;
+
+ /**
+ * Build a new Element
+ *
+ * @param Container $app
+ */
+ public function __construct(Former $former, $session)
{
- $this->app = $app;
+ $this->former = $former;
+ $this->session = $session;
}
/**
@@ -23,16 +43,16 @@ public function __construct($app)
*/
public function token()
{
- $csrf = $this->app['session']->getToken();
+ $csrf = $this->session->getToken();
- return $this->app['former']->hidden($csrf, $csrf)->__toString();
+ return (string) $this->former->hidden('_token', $csrf);
}
/**
* Creates a label tag
*
- * @param string $label The label content
* @param string $name The field the label's for
+ * @param string $label The label content
* @param array $attributes The label's attributes
* @return string A <label> tag
*/
@@ -40,7 +60,10 @@ public function label($label, $name = null, $attributes = array())
{
$label = Helpers::translate($label);
- return $this->app['meido.form']->label($name, $label, $attributes);
+ $attributes['for'] = $name;
+ $this->former->labels[] = $name;
+
+ return Element::create('label', $label, $attributes);
}
/**
@@ -54,7 +77,7 @@ public function legend($legend, $attributes = array())
{
$legend = Helpers::translate($legend);
- return '<legend'.$this->app['meido.html']->attributes($attributes).'>' .$legend. '</legend>';
+ return Element::create('legend', $legend, $attributes);
}
/**
View
87 src/Former/Form/Fields/Button.php
@@ -1,18 +1,44 @@
<?php
-/**
- * Button
- *
- * Button fields
- */
namespace Former\Form\Fields;
use Form;
use Former\Helpers;
use Former\Traits\Field;
+/**
+ * Button fields
+ */
class Button extends Field
{
- protected $app;
+ /**
+ * The Illuminate Container
+ *
+ * @var Container
+ */
+ protected $former;
+
+ /**
+ * The Button default element
+ *
+ * @var string
+ */
+ protected $element = 'input';
+
+ /**
+ * Default value for self-closing
+ *
+ * @var boolean
+ */
+ protected $isSelfClosing = true;
+
+ /**
+ * A list of class properties to be added to attributes
+ *
+ * @var array
+ */
+ protected $injectedProperties = array(
+ 'name', 'type', 'value',
+ );
////////////////////////////////////////////////////////////////////
/////////////////////////// CORE METHODS ///////////////////////////
@@ -21,39 +47,32 @@ class Button extends Field
/**
* Easier arguments order for button fields
*
- * @param string $type button/submit
- * @param string $value Its value
- * @param array $attributes Attributes
+ * @param Container $app The Illuminate Container
+ * @param string $type button/submit/reset/etc
+ * @param string $value The text of the button
+ * @param string $link Its link
+ * @param array $attributes Its attributes
*/
- public function __construct($app, $type, $value, $link, $attributes)
+ public function __construct(\Former\Former $former, $type, $value, $link, $attributes)
{
- $this->app = $app;
+ $this->former = $former;
+
$this->attributes = (array) $attributes;
$this->type = $type;
$this->value($value);
- // Add href to attributes if link
- if ($this->type == 'link') {
- $this->link = $link;
- }
- }
-
- /**
- * Renders the button
- *
- * @return string A form button
- */
- public function render()
- {
- $type = $this->type;
- $this->attributes['name'] = $this->name;
-
- // Link buttons
- if ($type == 'link') {
- return $this->app['meido.html']->to($this->link, $this->value, $this->attributes);
+ // Set correct element for the various button patterns
+ switch ($type) {
+ case 'button':
+ $this->element = 'button';
+ $this->isSelfClosing = false;
+ break;
+ case 'link':
+ $this->element = 'a';
+ $this->attributes['href'] = $link;
+ $this->isSelfClosing = false;
+ break;
}
-
- return $this->app['meido.form']->$type($this->value, $this->attributes);
}
////////////////////////////////////////////////////////////////////
@@ -77,9 +96,7 @@ public function isButton()
*/
public function value($value)
{
- $value = Helpers::translate($value);
-
- $this->value = $value;
+ $this->value = Helpers::translate($value);
return $this;
}
View
9 src/Former/Form/Fields/Checkbox.php
@@ -1,17 +1,16 @@
<?php
-/**
- * Checkbox
- *
- * My name is Bawksy you see
- */
namespace Former\Form\Fields;
use Former\Traits\Checkable;
+/**
+ * My name is Bawksy you see
+ */
class Checkbox extends Checkable
{
/**
* The current checkable type
+ *
* @var string
*/
protected $checkable = 'checkbox';
View
46 src/Former/Form/Fields/File.php
@@ -1,14 +1,13 @@
<?php
-/**
- * File
- *
- * Class for file fields
- */
namespace Former\Form\Fields;
+use HtmlObject\Input as HtmlInput;
use Former\Traits\Field;
use Laravel\File as LaravelFile;
+/**
+ * Class for file fields
+ */
class File extends Field
{
/**
@@ -23,6 +22,8 @@ class File extends Field
*/
private $mimeGroups = array('audio', 'video', 'image');
+ protected $injectedProperties = array('type', 'name');
+
////////////////////////////////////////////////////////////////////
/////////////////////////// CORE METHODS ///////////////////////////
////////////////////////////////////////////////////////////////////
@@ -30,21 +31,23 @@ class File extends Field
/**
* Easier arguments order for hidden fields
*
- * @param string $type hidden
- * @param string $name Field name
- * @param string $value Its value
- * @param array $attributes Attributes
+ * @param Container $app The Illuminate Container
+ * @param string $type file
+ * @param string $name Field name
+ * @param string $label Its label
+ * @param string $value Its value
+ * @param array $attributes Attributes
*/
- public function __construct($app, $type, $name, $label, $value, $attributes)
+ public function __construct(\Former\Former $former, $type, $name, $label, $value, $attributes)
{
- parent::__construct($app, $type, $name, $label, $value, $attributes);
-
// Multiple files field
- if ($this->isOfType('files')) {
- $this->multiple();
- $this->type = 'file';
- $this->name = $this->name.'[]';
+ if ($type == 'files') {
+ $attributes['multiple'] = 'true';
+ $type = 'file';
+ $name = $name.'[]';
}
+
+ parent::__construct($former, $type, $name, $label, $value, $attributes);
}
/**
@@ -56,10 +59,10 @@ public function render()
{
// Maximum file size
$hidden = $this->maxSize
- ? $this->app['meido.form']->hidden('MAX_FILE_SIZE', $this->maxSize)
+ ? HtmlInput::hidden('MAX_FILE_SIZE', $this->maxSize)
: null;
- return $this->app['meido.form']->input($this->type, $this->name, $this->value, $this->attributes).$hidden;
+ return parent::render().$hidden;
}
////////////////////////////////////////////////////////////////////
@@ -69,10 +72,12 @@ public function render()
/**
* Set which types of files are accepted by the file input
*
- * @param string $mimes* A list of extensions/mimes/groups to accept
+ * @param string $mimes A list of extensions/mimes/groups to accept
*/
public function accept()
{
+ $mimes = array();
+
// Transform all extensions/groups to mime types
foreach (func_get_args() as $mime) {
@@ -92,7 +97,8 @@ public function accept()
/**
* Set a maximum size for files
*
- * @param integer $size A maximum size in Kb
+ * @param integer $size A maximum size
+ * @param string $units The size's unit
*/
public function max($size, $units = 'KB')
{
View
17 src/Former/Form/Fields/Hidden.php
@@ -1,13 +1,13 @@
<?php
-/**
- * Hidden
- *
- * Class for hidden fields
- */
namespace Former\Form\Fields;
+use Former\Former;
use Former\Traits\Field;
+use HtmlObject\Input as HtmlInput;
+/**
+ * Class for hidden fields
+ */
class Hidden extends Field
{
@@ -18,14 +18,15 @@ class Hidden extends Field
/**
* Easier arguments order for hidden fields
*
+ * @param Former $former The Former instance
* @param string $type hidden
* @param string $name Field names
* @param string $value Its value
* @param array $attributes Attributes
*/
- public function __construct($app, $type, $name, $value, $attributes)
+ public function __construct(Former $former, $type, $name, $value, $attributes)
{
- parent::__construct($app, $type, $name, '', $value, $attributes);
+ parent::__construct($former, $type, $name, '', $value, $attributes);
}
/**
@@ -35,6 +36,6 @@ public function __construct($app, $type, $name, $value, $attributes)
*/
public function render()
{
- return $this->app['meido.form']->hidden($this->name, $this->value, $this->attributes);
+ return HtmlInput::create('hidden', $this->name, $this->value, $this->attributes)->render();
}
}
View
45 src/Former/Form/Fields/Input.php
@@ -1,21 +1,27 @@
<?php
-/**
- * Input
- *
- * Renders all basic input types
- */
namespace Former\Form\Fields;
use Former\Helpers;
use Former\Traits\Field;
+/**
+ * Renders all basic input types
+ */
class Input extends Field
{
/**
* Current datalist stored
+ *
* @var array
*/
- private $datalist = array();
+ protected $datalist = array();
+
+ /**
+ * Properties to be injected as attributes
+ *
+ * @var array
+ */
+ protected $injectedProperties = array('type', 'name', 'value');
////////////////////////////////////////////////////////////////////
/////////////////////////// CORE METHODS ///////////////////////////
@@ -23,13 +29,21 @@ class Input extends Field
/**
* Build an input field
+ *
+ * @param Container $app The Illuminate Container
+ * @param string $type The input type
+ * @param string $name Field name
+ * @param string $label Its label
+ * @param string $value Its value
+ * @param array $attributes Attributes
*/
- public function __construct($app, $type, $name, $label, $value, $attributes)
+ public function __construct(\Former\Former $former, $type, $name, $label, $value, $attributes)
{
- parent::__construct($app, $type, $name, $label, $value, $attributes);
+ parent::__construct($former, $type, $name, $label, $value, $attributes);
// Multiple models population
if (is_array($this->value)) {
+ $values = array();
foreach($this->value as $value) $values[] = is_object($value) ? $value->__toString() : $value;
if (isset($values)) $this->value = implode(', ', $values);
}
@@ -45,8 +59,10 @@ public function render()
// Particular case of the search element
if($this->isOfType('search')) $this->asSearch();
+ $this->setId();
+
// Render main input
- $input = $this->app['meido.form']->input($this->type, $this->name, $this->value, $this->attributes);
+ $input = parent::render();
// If we have a datalist to append, print it out
if ($this->datalist) {
@@ -63,7 +79,9 @@ public function render()
/**
* Adds a datalist to the current field
*
- * @param array $datalist An array to use a source
+ * @param array $datalist An array to use a source
+ * @param string $value The field to use as value
+ * @param string $key The field to use as key
*/
public function useDatalist($datalist, $value = null, $key = null)
{
@@ -72,7 +90,7 @@ public function useDatalist($datalist, $value = null, $key = null)
$list = $this->list ?: 'datalist_'.$this->name;
// Create the link to the datalist
- $this->list($list);
+ $this->list = $list;
$this->datalist = $datalist;
return $this;
@@ -88,7 +106,7 @@ public function useDatalist($datalist, $value = null, $key = null)
private function asSearch()
{
$this->type = 'text';
- $this->attributes = Helpers::addClass($this->attributes, 'search-query');
+ $this->addClass('search-query');
return $this;
}
@@ -96,6 +114,9 @@ private function asSearch()
/**
* Renders a datalist
*
+ * @param string $id The datalist's id attribute
+ * @param array $values Its values
+ *
* @return string A <datalist> tag
*/
private function createDatalist($id, $values)
View
8 src/Former/Form/Fields/Radio.php
@@ -1,13 +1,11 @@
<?php
-/**
- * Radio
- *
- * Creating radios elements since 1873
- */
namespace Former\Form\Fields;
use Former\Traits\Checkable;
+/**
+ * Creating radios elements since 1873
+ */
class Radio extends Checkable
{
/**
View
108 src/Former/Form/Fields/Select.php
@@ -1,27 +1,34 @@
<?php
-/**
- * Select
- *
- * Everything list-related (select, multiselect, ...)
- */
namespace Former\Form\Fields;
-use Former\Traits\Field;
use Former\Helpers;
+use Former\Traits\Field;
+use HtmlObject\Element;
+/**
+ * Everything list-related (select, multiselect, ...)
+ */
class Select extends Field
{
/**
- * The select options
- * @var array
+ * The select's placeholder
+ * @var string
*/
- private $options = array();
+ private $placeholder = null;
/**
- * The select's placeholder
+ * The select's element
+ *
* @var string
*/
- private $placeholder = null;
+ protected $element = 'select';
+
+ /**
+ * The select's self-closing state
+ *
+ * @var boolean
+ */
+ protected $isSelfClosing = false;
////////////////////////////////////////////////////////////////////
/////////////////////////// CORE METHODS ///////////////////////////
@@ -30,19 +37,20 @@ class Select extends Field
/**
* Easier arguments order for selects
*
- * @param string $type select or multiselect
- * @param string $name Field name
- * @param string $label Field label
- * @param array $options Its options
- * @param mixed $selected Selected entry
- * @param array $attributes Attributes
+ * @param Container $app The Illuminate Container
+ * @param string $type file
+ * @param string $name Field name
+ * @param string $label Its label
+ * @param array $options The select's options
+ * @param string $selected The selected option
+ * @param array $attributes Attributes
*/
- public function __construct($app, $type, $name, $label, $options, $selected, $attributes)
+ public function __construct(\Former\Former $former, $type, $name, $label, $options, $selected, $attributes)
{
- if($options) $this->options = $options;
if($selected) $this->value = $selected;
+ if($options) $this->options($options);
- parent::__construct($app, $type, $name, $label, $selected, $attributes);
+ parent::__construct($former, $type, $name, $label, $selected, $attributes);
// Multiple models population
if (is_array($this->value)) {
@@ -58,31 +66,49 @@ public function __construct($app, $type, $name, $label, $options, $selected, $at
*/
public function render()
{
- $name = $this->name;
-
// Multiselects
if ($this->isOfType('multiselect')) {
if (!isset($this->attributes['id'])) {
- $this->setAttribute('id', $name);
+ $this->setAttribute('id', $this->name);
}
$this->multiple();
- $name .= '[]';
- }
+ $this->name .= '[]';
- // Render select
- $select = $this->app['meido.form']->select($name, $this->options, $this->value, $this->attributes);
+ if ($this->hasChildren() and is_array($this->value)) {
+ foreach ($this->value as $value) {
+ $this->getChild($value)->selected('selected');
+ }
+ }
+ } else {
+ if ($this->hasChildren() and $this->value) {
+ $this->getChild($this->value)->selected('selected');
+ }
+ }
// Add placeholder text if any
- if ($this->placeholder) {
- $placeholder = array('value' => '', 'disabled' => '');
- if(!$this->value) $placeholder['selected'] = '';
- $placeholder = '<option'.$this->app['meido.html']->attributes($placeholder).'>' .$this->placeholder. '</option>';
-
- $select = preg_replace('#<select([^>]+)>#', '$0'.$placeholder, $select);
+ if ($placeholder = $this->getPlaceholder()) {
+ array_unshift($this->children, $placeholder);
}
- return $select;
+ $this->value = null;
+
+ return parent::render();
+ }
+
+ /**
+ * Get the Select's placeholder
+ *
+ * @return Element
+ */
+ protected function getPlaceholder()
+ {
+ if (!$this->placeholder) return false;
+
+ $attributes = array('value' => '', 'disabled' => 'disabled');
+ if(!$this->value) $attributes['selected'] = 'selected';
+
+ return Element::create('option', $this->placeholder, $attributes);
}
////////////////////////////////////////////////////////////////////
@@ -92,13 +118,15 @@ public function render()
/**
* Set the select options
*
- * @param array $options The options as an array
+ * @param array $_options The options as an array
* @param mixed $selected Facultative selected entry
* @param boolean $valuesAsKeys Whether the array's values should be used as
* the option's values instead of the array's keys
*/
public function options($_options, $selected = null, $valuesAsKeys = false)
{
+ $options = array();
+
// Automatically fetch Lang objects for people who store translated options lists
if ($_options instanceof \Laravel\Lang) {
$_options = $_options->get();
@@ -109,7 +137,11 @@ public function options($_options, $selected = null, $valuesAsKeys = false)
foreach($_options as $v) $options[$v] = $v;
} else $options = $_options;
- $this->options = $options;
+ foreach ($options as $key => $option) {
+ $options[$key]