Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

 
Reply to this topicStart new topic
> [ZendFramework] Zamiana kolejności pól formularza
nexis
post 14.09.2009, 11:54:43
Post #1





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Tworzę formularz za pomocą Zend_Form:
  1. foreach ($optional as $key) {
  2. $this->addElement('checkbox', $key, array(
  3. 'required' => false,
  4. 'value' => '1'
  5. ));
  6. }

który generuje mniej więcej taki kod:
  1. <dl>
  2. <dt id="firstname-label">
  3. <label for="firstname" class="optional">
  4. Jan
  5. </label>
  6. </dt>
  7. <dd id="firstname-element">
  8. <input type="hidden" name="firstname" value="0" /><input type="checkbox" name="firstname" id="firstname" value="1" checked="checked" />
  9. </dd>
  10. <dt id="lastname-label">
  11. <label for="lastname" class="optional">
  12. Kowalski
  13. </label>
  14. </dt>
  15. <dd id="lastname-element">
  16. <input type="hidden" name="lastname" value="0" /><input type="checkbox" name="lastname" id="lastname" value="1" checked="checked" />
  17. </dd>
  18. </dl>

Powyższy kod daje taki widok:

Ja chciałbym jednak uzyskać następujący widok:


Za pomocą CSS chyba nie da rady, ponieważ element DT jest przed DD, stąd pomysł, żeby te dwa elementy zamienić kolejnością. Ale jak?


--------------------
Zend Certified Engineer

Kliknij POMÓGŁ jeśli moja odpowiedź okazała się użyteczna!
Go to the top of the page
+Quote Post
seth-kk
post 14.09.2009, 12:23:11
Post #2





Grupa: Zarejestrowani
Postów: 444
Pomógł: 79
Dołączył: 26.05.2009

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


za pomoca css:
  1. .zend_form {
  2. overflow: hidden;
  3. }
  4. .zend_form dt {
  5. width: 25%;
  6. float: right;
  7. clear: right;
  8. }
  9. .zend_form dd {
  10. width: 75%;
  11. float: right;
  12. }

lub zamieniajac wartosci 'tag' w Zend_Form_Decorator_Label i Zend_Form_Decorator_HtmlTag


--------------------
Go to the top of the page
+Quote Post
batman
post 14.09.2009, 12:24:52
Post #3





Grupa: Moderatorzy
Postów: 2 921
Pomógł: 269
Dołączył: 11.08.2005
Skąd: 127.0.0.1




Takie coś możesz uzyskać ustawiając placement na APPEND lub PREPEND w dekoratorze. Nie pamiętam dokładnie, w którym miejscu to się robi, musiałbyś sprawdzić w dokumentacji.


--------------------
I would love to change the world, but they won't give me the source code.
My software never has bugs. It just develops random features.
Go to the top of the page
+Quote Post
nexis
post 14.09.2009, 22:36:26
Post #4





Grupa: Zarejestrowani
Postów: 1 012
Pomógł: 109
Dołączył: 26.09.2003
Skąd: nexis.pl

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


Cytat(seth-kk @ 14.09.2009, 13:23:11 ) *
za pomoca css:
  1. .zend_form {
  2. overflow: hidden;
  3. }
  4. .zend_form dt {
  5. width: 25%;
  6. float: right;
  7. clear: right;
  8. }
  9. .zend_form dd {
  10. width: 75%;
  11. float: right;
  12. }

To nie działa.
Cytat(seth-kk @ 14.09.2009, 13:23:11 ) *
za pomoca css:
  1. .zend_form {
  2. overflow: hidden;
  3. }
  4. .zend_form dt {
  5. width: 25%;
  6. float: right;
  7. clear: right;
  8. }
  9. .zend_form dd {
  10. width: 75%;
  11. float: right;
  12. }

lub zamieniajac wartosci 'tag' w Zend_Form_Decorator_Label i Zend_Form_Decorator_HtmlTag

A co mi da zmiana tagu? Nadal kolejność będzie taka sama.


--------------------
Zend Certified Engineer

Kliknij POMÓGŁ jeśli moja odpowiedź okazała się użyteczna!
Go to the top of the page
+Quote Post
seth-kk
post 14.09.2009, 22:51:55
Post #5





Grupa: Zarejestrowani
Postów: 444
Pomógł: 79
Dołączył: 26.05.2009

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


Cytat(nexis @ 14.09.2009, 23:36:26 ) *
To nie działa.

przed wklejeniem sprawdzilem i dzialalo (xhtml 1.0 strict)

Cytat(nexis @ 14.09.2009, 23:36:26 ) *
A co mi da zmiana tagu? Nadal kolejność będzie taka sama.

zapomnialem o prepend dla labela co uzupelnil batman


--------------------
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: 21.06.2025 - 13:43