Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework] Obługa multiple input
Jav
post 9.05.2012, 12:22:00
Post #1





Grupa: Zarejestrowani
Postów: 1
Pomógł: 0
Dołączył: 7.05.2012

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


Mam taki oto formularz.

  1. class Admin_Form_Photo extends Zend_Form
  2. {
  3. public function init()
  4. {
  5. $this->setMethod('post');
  6.  
  7. $this->addElement(new Zend_Form_Element_File('photo', array(
  8. 'label' => 'Zdjęcie',
  9. 'multiple' => 'multiple',
  10. 'required' => true
  11. )));
  12.  
  13. $this->getElement('photo')->setAttrib('name', 'photos[]');
  14.  
  15. $this->addElement(new Zend_Form_Element_Submit('submit', array(
  16. 'label' => 'Wyślij'
  17. )));
  18. }
  19. }


Tym formularzem przesyłam kilka plików na raz. Czy ktoś mógłby mi wytłumaczyć w jaki sposób odebrać dane tych plików w formularzu też żeby były dostępne przez $form->getValues() ? Standardowe odbieranie w ten sposób:
  1. if($this->getRequest()->isPost()){
  2. $form = new Admin_Form_Photo();
  3. if($form->isValid($this->getRequest()->getPost())){
  4. $data = $form->getValues();
  5. }
  6. }

Zwraca mi pustą tablicę.

Ten post edytował Jav 9.05.2012, 12:26:12
Go to the top of the page
+Quote Post
d3ut3r
post 9.05.2012, 13:43:44
Post #2





Grupa: Zarejestrowani
Postów: 709
Pomógł: 176
Dołączył: 24.10.2010

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


  1. $this->addElement(new Zend_Form_Element_File('photo', array(
  2. 'label' => 'Zdjęcie',
  3. 'multiple' => 'multiple',
  4. 'required' => true,
  5. 'isArray' => true
  6. )));


powinno zadziałać i zwracać tablicę plików.


--------------------
http://d3ut3r.wordpress.com/ | mysql_* jest przestarzałe UŻYWAJ PDO!
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: 5.07.2025 - 13:39