Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework] Form select
Eagle
post 12.04.2010, 10:46:02
Post #1





Grupa: Zarejestrowani
Postów: 170
Pomógł: 14
Dołączył: 16.03.2007

Ostrzeżenie: (0%)
-----


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. }
Go to the top of the page
+Quote Post
melkorm
post 12.04.2010, 14:11:43
Post #2





Grupa: Zarejestrowani
Postów: 1 366
Pomógł: 261
Dołączył: 23.09.2008
Skąd: Bydgoszcz

Ostrzeżenie: (0%)
-----


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.

Ten post edytował melkorm 12.04.2010, 14:14:53


--------------------
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Wersja Lo-Fi Aktualny czas: 31.07.2025 - 10:54