PageRenderTime 53ms CodeModel.GetById 21ms RepoModel.GetById 0ms app.codeStats 0ms

/Nette/Forms/Controls/RepeaterControl.php

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