Witam,
Otoż chciałbym zastosować edycje stron w kilku językach. Gdybym miał napisać formularz włąsnoręcznie zrobiłbym to mniej więcej tak:

  1. <form method="post">
  2. <fieldset id="pl">
  3. <input type="text" name="pl[title]">
  4. <input type="text" name="pl[description]">
  5. </fieldset>
  6.  
  7. <fieldset id="eng" class="hide">
  8. <input type="text" name="eng[title]">
  9. <input type="text" name="eng[description]">
  10. </fieldset>
  11. </form>


W momencie wysłania formularza otrzymałbym tablicę (pisane z głowy więć proszę nie patrzeć na błędy bo nie o to chodzi)
  1. [pl] => Array {
  2. 'title' => '...',
  3. 'description' => '...'
  4. },
  5. [eng] => Array {
  6. 'title' => '...',
  7. 'description' => '...'
  8. }
  9. }


Jednak przy zastosowaniu Zend_Form_SubForm wszystkie pola o nazwie pl[title], eng[title] itp. zamienia na pltitle, engtitle itd.. Czy można to zmienić aby efekt był jak formularz wyżej.

Oto kod który używam do budowy formularza:
  1. if (Zend_Registry::isRegistered('langs'))
  2. {
  3. $langs = Zend_Registry::get('langs');
  4. if ($langs)
  5. {
  6. foreach ($langs as $k=>$v)
  7. {
  8. $subFormName = 'subform_'.$v['code'];
  9. $$subFormName = new Zend_Form_SubForm();
  10.  
  11. # Tworzenie pola title
  12. $$subFormName->addElement('text', $v['code'].'[title]', array(
  13. 'label' => 'Tytuł strony',
  14. 'validators' => array(
  15. array('NotEmpty', true, array(
  16. 'messages' => array(
  17. 'isEmpty' => 'Pole nie może być puste'
  18. ))),
  19. array('StringLength', true, array(
  20. 'min' => false,
  21. 'max' => '100',
  22. 'messages' => array(
  23. 'stringLengthTooLong' => 'Wartość jest zbyt długi. Maksymalna ilość znaków wynosi %max%.'
  24. ))),
  25. ),
  26. 'required' => true,
  27. 'class' => 'text',
  28. ));
  29. # End
  30.  
  31. # Tworzenie pola short_descriptions
  32. $$subFormName->addElement('textarea', $v['code'].'[descriptions]', array(
  33. 'label' => 'Krótki opis strony',
  34. 'validators' => array(
  35. array('NotEmpty', true, array(
  36. 'messages' => array(
  37. 'isEmpty' => 'Pole nie może być puste'
  38. ))),
  39. array('StringLength', true, array(
  40. 'min' => false,
  41. 'max' => '200',
  42. 'messages' => array(
  43. 'stringLengthTooLong' => 'Wartość jest zbyt długi. Maksymalna ilość znaków wynosi %max%.'
  44. ))),
  45. ),
  46. 'required' => true,
  47. 'class' => 'text',
  48. ));
  49. # End
  50.  
  51. $$subFormName->setElementDecorators(array('Form'));
  52. $this->addSubForm($$subFormName, $v['code']);
  53. }
  54. }
  55. }