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 https://nette.org
  12. 12:  *
  13. 13:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  14. 14:  * @license    https://nette.org/license  Nette license
  15. 15:  * @link       https://nette.org
  16. 16:  * @category   Nette
  17. 17:  * @package    Nette\Forms
  18. 18:  * @version    $Id$
  19. 19:  */
  20. 20:  
  21. 21:  
  22. 22:  
  23. 23: require_once dirname(__FILE__'/../../Forms/FormContainer.php';
  24. 24:  
  25. 25: require_once dirname(__FILE__'/../../Forms/IFormControl.php';
  26. 26:  
  27. 27:  
  28. 28:  
  29. 29: /**
  30. 30:  * A control that repeats a specified prototype for each item in the list.
  31. 31:  *
  32. 32:  * @author     David Grudl
  33. 33:  * @copyright  Copyright (c) 2004, 2009 David Grudl
  34. 34:  * @package    Nette\Forms
  35. 35:  */
  36. 36: class RepeaterControl extends FormContainer /*implements IFormControl*/
  37. 37: {
  38. 38:     /** @var int */
  39. 39:     public $repeatCount = 3;
  40. 40:  
  41. 41:     /** @var int */
  42. 42:     public $repeatMin = 1;
  43. 43:  
  44. 44:     /** @var int */
  45. 45:     public $repeatMax = 0;
  46. 46:  
  47. 47:     /** @var array */
  48. 48:     protected $value;
  49. 49:  
  50. 50:  
  51. 51:     /**
  52. 52:      */
  53. 53:     public function __construct()
  54. 54:     {
  55. 55:         throw new NotImplementedException;
  56. 56:     }
  57. 57:  
  58. 58:  
  59. 59:  
  60. 60:     /**
  61. 61:      * Set value.
  62. 62:      * @param  mixed 
  63. 63:      * @return void 
  64. 64:      */
  65. 65:     public function setValue($value)
  66. 66:     {
  67. 67:         if (is_array($value)) {
  68. 68:             $this->value = $value;
  69. 69:         else {
  70. 70:             $this->value = array();
  71. 71:         }
  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:      * @param  array 
  90. 90:      * @return void 
  91. 91:      */
  92. 92:     public function loadHttpData($data)
  93. 93:     {
  94. 94:         $name $this->getName();
  95. 95:         $this->setValue(isset($data[$name]$data[$namearray());
  96. 96:     }
  97. 97:  
  98. 98: }