html.checkboxes

Posledné novinky

Asi hotovo.

Takže, už to vyzerá byť dokončené. Od minula som pridal animovanie cez timer a možnosť upravovať...


14.12.2014 19:13
Kategória: Projekt key-framing a interpolácia

Prvá funkčná verzia

Po tejto sobote mám už prvý reálny výsledok. Viem nastavovať keyframe s pozíciou kamery, pohľadom...


14.12.2014 00:23
Kategória: Projekt key-framing a interpolácia
Choď do archívu >>

html.checkboxes

Funkcia html.checkboxes vygeneruje pole elementov <input type="checkbox" />.

Parameter Vyžadovaný Východzia hodnota Význam
name Áno

Pomenovanie pre checkboxy.

Podporuje aj pomenovanie vo forme pola.

values Nie array()

Pole hodnôt vo formáte:

array('hodnota' => 'popis', ...)

cols Nie 1

Počet stĺpcov. Ak je väčšie ako 1, bude generovať mriežku v tabuľke.

class Nie Reťazec: 'swift_checkboxes'

Prefix názvov tried pre jednotlivé vygenerované elementy.

selected Nie array()

Pole označených prvkov. Má štruktúru:

array('hodnota', ...)

Príklad

Majme jednoduchý php kód:

Zobraziť čistý text Zobraziť zvíraznený text
  1. <?php
  2. ...
  3.  
  4. $swift->assign('options', array(
  5. 0 => 'NULA',
  6. 1 => 'JEDNA',
  7. 2 => 'DVA',
  8. 3 => 'TRI',
  9. 4 => 'STYRI',
  10. 5 => 'PAT',
  11. 6 => 'SEST',
  12. 7 => 'SEDEM',
  13. 8 => 'OSEM',
  14. 9 => 'DEVAT',
  15. ));
  16.  
  17. ...
  18. ?>

A html kód v šablóne:

Zobraziť čistý text Zobraziť zvíraznený text
  1. <div>{s:html.checkboxes(name="myboxes[1]" values=$options cols=3 selected="{0:1, 1:5, 2:9}")}</div>

Výsledok (pozn.: štruktúra kódu v príklade je upravená):

Zobraziť čistý text Zobraziť zvíraznený text
  1. <div>
  2. <table class="swift_checkboxes_table">
  3. <tr class="swift_checkboxes_row_1">
  4. <td class="swift_checkboxes_col_0">
  5. <input type="checkbox" name="myboxes[1]" value="0" id="id_myboxes_1_0" />
  6. <label for="id_myboxes_1_0">NULA
  7. </label></td>
  8. <td class="swift_checkboxes_col_1">
  9. <input type="checkbox" name="myboxes[1]" value="1" checked="checked" id="id_myboxes_1_1" />
  10. <label for="id_myboxes_1_1">JEDNA
  11. </label></td>
  12. <td class="swift_checkboxes_col_2">
  13. <input type="checkbox" name="myboxes[1]" value="2" id="id_myboxes_1_2" />
  14. <label for="id_myboxes_1_2">DVA
  15. </label></td>
  16. </tr>
  17. <tr class="swift_checkboxes_row_2">
  18. <td class="swift_checkboxes_col_3">
  19. <input type="checkbox" name="myboxes[1]" value="3" id="id_myboxes_1_3" />
  20. <label for="id_myboxes_1_3">TRI
  21. </label></td>
  22. <td class="swift_checkboxes_col_4">
  23. <input type="checkbox" name="myboxes[1]" value="4" id="id_myboxes_1_4" />
  24. <label for="id_myboxes_1_4">STYRI
  25. </label></td>
  26. <td class="swift_checkboxes_col_5">
  27. <input type="checkbox" name="myboxes[1]" value="5" checked="checked" id="id_myboxes_1_5" />
  28. <label for="id_myboxes_1_5">PAT
  29. </label></td>
  30. </tr>
  31. <tr class="swift_checkboxes_row_3">
  32. <td class="swift_checkboxes_col_6">
  33. <input type="checkbox" name="myboxes[1]" value="6" id="id_myboxes_1_6" />
  34. <label for="id_myboxes_1_6">SEST
  35. </label></td>
  36. <td class="swift_checkboxes_col_7">
  37. <input type="checkbox" name="myboxes[1]" value="7" id="id_myboxes_1_7" />
  38. <label for="id_myboxes_1_7">SEDEM
  39. </label></td>
  40. <td class="swift_checkboxes_col_8">
  41. <input type="checkbox" name="myboxes[1]" value="8" id="id_myboxes_1_8" />
  42. <label for="id_myboxes_1_8">OSEM
  43. </label></td>
  44. </tr>
  45. <tr class="swift_checkboxes_row_4">
  46. <td class="swift_checkboxes_col_9">
  47. <input type="checkbox" name="myboxes[1]" value="9" checked="checked" id="id_myboxes_1_9" />
  48. <label for="id_myboxes_1_9">DEVAT
  49. </label></td>
  50. <td class="swift_checkboxes_col_empty"></td>
  51. <td class="swift_checkboxes_col_empty"></td>
  52. </tr>
  53. </tbody>
  54. </table>
  55. </div>