You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

layout-formlayout.asciidoc 2.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. ---
  2. title: FormLayout
  3. order: 5
  4. layout: page
  5. ---
  6. [[layout.formlayout]]
  7. = [classname]#FormLayout#
  8. ifdef::web[]
  9. [.sampler]
  10. image:{live-demo-image}[alt="Live Demo", link="http://demo.vaadin.com/sampler/#ui/layout/form-layout"]
  11. endif::web[]
  12. [classname]#FormLayout# lays the components and their captions out in two
  13. columns, with optional indicators for required fields and errors that can be
  14. shown for each field. The field captions can have an icon in addition to the
  15. text. [classname]#FormLayout# is an ordered layout and much like
  16. [classname]#VerticalLayout#. For description of margins, spacing, and other
  17. features in ordered layouts, see
  18. <<dummy/../../../framework/layout/layout-orderedlayout#layout.orderedlayout, "VerticalLayout and HorizontalLayout">>.
  19. The following example shows typical use of [classname]#FormLayout# in a form:
  20. [source, java]
  21. ----
  22. FormLayout form = new FormLayout();
  23. TextField tf1 = new TextField("Name");
  24. tf1.setIcon(FontAwesome.USER);
  25. tf1.setRequired(true);
  26. form.addComponent(tf1);
  27. TextField tf2 = new TextField("Street address");
  28. tf2.setIcon(FontAwesome.ROAD);
  29. form.addComponent(tf2);
  30. TextField tf3 = new TextField("Postal code");
  31. tf3.setIcon(FontAwesome.ENVELOPE);
  32. form.addComponent(tf3);
  33. ----
  34. The resulting layout will look as follows. The error message shows in a tooptip
  35. when you hover the mouse pointer over the error indicator.
  36. [[figure.layout.formlayout]]
  37. .A [classname]#FormLayout# Layout for Forms
  38. image::img/formlayout-example1.png[]
  39. [[layout.formlayout.css]]
  40. == CSS Style Rules
  41. [source, css]
  42. ----
  43. .v-formlayout {}
  44. .v-formlayout .v-caption {}
  45. /* Columns in a field row. */
  46. .v-formlayout-contentcell {} /* Field content. */
  47. .v-formlayout-captioncell {} /* Field caption. */
  48. .v-formlayout-errorcell {} /* Field error indicator. */
  49. /* Overall style of field rows. */
  50. .v-formlayout-row {}
  51. .v-formlayout-firstrow {}
  52. .v-formlayout-lastrow {}
  53. /* Required field indicator. */
  54. .v-formlayout .v-required-field-indicator {}
  55. .v-formlayout-captioncell .v-caption
  56. .v-required-field-indicator {}
  57. /* Error indicator. */
  58. .v-formlayout-cell .v-errorindicator {}
  59. .v-formlayout-error-indicator .v-errorindicator {}
  60. ----
  61. The top-level element of [classname]#FormLayout# has the
  62. [literal]#++v-formlayout++# style. The layout is tabular with three columns: the
  63. caption column, the error indicator column, and the field column. These can be
  64. styled with [literal]#++v-formlayout-captioncell++#,
  65. [literal]#++v-formlayout-errorcell++#, and
  66. [literal]#++v-formlayout-contentcell++#, respectively. While the error indicator
  67. is shown as a dedicated column, the indicator for required fields is currently
  68. shown as a part of the caption column.
  69. For information on setting margins and spacing, see also
  70. <<dummy/../../../framework/layout/layout-orderedlayout#layout.orderedlayout.spacing,"Spacing
  71. in Ordered Layouts">> and
  72. <<dummy/../../../framework/layout/layout-settings#layout.settings.margins, "Layout Margins">>.