Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [ZendFramework] Form select
Forum PHP.pl > Forum > PHP > Frameworki
Eagle
Nadpisałem domyślną klase Zend_Form_Element_Select (niby nic takiego - czyszczenie dekoratorów i używanie w nazwie "[]").
Jednak podczas renderowania dodawany jest parametr
Kod
<slect ... multiple="multiple">

Przy używaniu Zend_Form_Element_Select element wyświetla się poprawnie - lista jest rozwijana.
Widzi ktoś co przeoczyłem ?

Pozdrawiam

Element tworzę tak:
  1. $pole = new Abc_Form_Element_Select('pole');
  2. $pole->setMultiOptions($elementy)
  3. ->setRequired(true);

  1. class Abc_Form_Element_Select extends Zend_Form_Element_Select
  2. {
  3. /**
  4.   * Constructor
  5.   */
  6. public function __construct($spec, $options = null)
  7. {
  8. parent::__construct($spec, $options);
  9.  
  10. $this->clearDecorators();
  11. $this->addDecorator('ViewHelper')
  12. ->addDecorator('Errors');
  13. }
  14.  
  15. /**
  16.   * Set element name
  17.   */
  18. public function setName($name)
  19. {
  20. $name = $this->filterName($name, true);
  21.  
  22. if ('' === $name) {
  23. require_once 'Zend/Form/Exception.php';
  24. throw new Zend_Form_Exception('Invalid name provided; must contain only valid variable characters and be non-empty');
  25. }
  26. $this->_name = $name;
  27. return $this;
  28. }
  29. }
melkorm
Zend_View_Helper_FormSelect
  1. [...]
  2. 77 if (substr($name, -2) == '[]') {
  3. 78 // multiple implied by the name
  4. 79 $multiple = ' multiple="multiple"';
  5. }
  6. [...]


Dlatego smile.gif

Edit:
ustaw atrybut multiple na false, powinno pomóc.*

*edited.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.