Source for file RepeaterControl.php

Documentation is available at RepeaterControl.php

  1. 1: <?php
  2. 2:  
  3. 3: /**
  4. 4:  * Nette Framework
  5. 5:  *
  6. 6:  * Copyright (c) 2004, 2009 David Grudl (http://davidgrudl.com)
  7. 7:  *
  8. 8:  * This source file is subject to the "Nette license" that is bundled
  9. 9:  * with this package in the file license.txt.
  10. 10:  *
  11. 11:  * For more information please see http://nettephp.com
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    http://nettephp.com/license  Nette license
  15. 15:  * @link       http://nettephp.com
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette\Forms
  18. 18:  */
  19. 19:  
  20. 20:  
  21. 21:  
  22. 22: require_once dirname(__FILE__'/../../Forms/FormContainer.php';
  23. 23:  
  24. 24: require_once dirname(__FILE__'/../../Forms/IFormControl.php';
  25. 25:  
  26. 26:  
  27. 27:  
  28. 28: /**
  29. 29:  * A control that repeats a specified prototype for each item in the list.
  30. 30:  *
  31. 31:  * @author     David Grudl
  32. 32:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  33. 33:  * @package    Nette\Forms
  34. 34:  */
  35. 35: class RepeaterControl extends FormContainer /*implements IFormControl*/
  36. 36: {
  37. 37:     /** @var int */
  38. 38:     public $repeatCount = 3;
  39. 39:  
  40. 40:     /** @var int */
  41. 41:     public $repeatMin = 1;
  42. 42:  
  43. 43:     /** @var int */
  44. 44:     public $repeatMax = 0;
  45. 45:  
  46. 46:     /** @var array */
  47. 47:     protected $value;
  48. 48:  
  49. 49:  
  50. 50:     /**
  51. 51:      */
  52. 52:     public function __construct()
  53. 53:     {
  54. 54:         throw new NotImplementedException;
  55. 55:     }
  56. 56:  
  57. 57:  
  58. 58:  
  59. 59:     /**
  60. 60:      * Set value.
  61. 61:      * @param  mixed 
  62. 62:      * @return RepeaterControl  provides a fluent interface
  63. 63:      */
  64. 64:     public function setValue($value)
  65. 65:     {
  66. 66:         if (is_array($value)) {
  67. 67:             $this->value = $value;
  68. 68:         else {
  69. 69:             $this->value = array();
  70. 70:         }
  71. 71:         return $this;
  72. 72:     }
  73. 73:  
  74. 74:  
  75. 75:  
  76. 76:     /**
  77. 77:      * Get value.
  78. 78:      * @return mixed 
  79. 79:      */
  80. 80:     public function getValue()
  81. 81:     {
  82. 82:         return $this->value;
  83. 83:     }
  84. 84:  
  85. 85:  
  86. 86:  
  87. 87:     /**
  88. 88:      * Load HTTP data.
  89. 89:      * @return void 
  90. 90:      */
  91. 91:     public function loadHttpData()
  92. 92:     {
  93. 93:         $name $this->getName();
  94. 94:         $this->setValue(isset($data[$name]$data[$namearray());
  95. 95:     }
  96. 96:  
  97. 97: }