Changeset 4543
- Timestamp:
- 04/29/08 06:37:17 (3 months ago)
- Files:
-
- projects/ToscaWidgetsForms/trunk/docs/tutorials/date_picker.png (added)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/movie_form.png (added)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/pylons_two.rst (modified) (9 diffs)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/text_area.png (added)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/tg2.rst (added)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/tutorial_index.rst (modified) (1 diff)
- projects/ToscaWidgetsForms/trunk/docs/tutorials/validators.png (added)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
projects/ToscaWidgetsForms/trunk/docs/tutorials/pylons_two.rst
r4540 r4543 1 .. _pylons_tutorial_two: 2 1 3 Using tw.forms with Pylons. Part 2 2 4 ================================== 5 6 .. currentmodule:: tw.forms.fields 3 7 4 8 Using fancy fields … … 19 23 It has two mechanisms to "inject" these resources: 20 24 21 * The "official" one which is copied from the way TurboGears' widgets injects 22 them. This method involves a "master" or "base" template which is inherited 25 * The "soon-to-be-deprecated" one which is copied from the way 26 TurboGears' widgets injects them. 27 This method involves a "master" or "base" template which is inherited 23 28 by every template you want to display widgets on, a special container in 24 29 which you pass widgets to the template from the controller and a wrapper 25 around the (deprecated I believe) ``render_response`` Pylons' function. 30 around the ``render_response`` Pylons' function. This method is a **pain** to 31 set up and forces widgets to be passed from the controller to the template 32 blurring the separation beteween the view and controller layers. 26 33 27 * The (now not so much) "experimental" one which is based on an idea that28 Ian Bicking expressed in his `blog <http://blog.ianbicking.org/lxml-transformations.html>`_.34 * The "soon-to-become-official" one which is based on an idea that 35 Ian Bicking expressed in his `blog`_. 29 36 This method is the recommended approach for two important reasons: 30 37 … … 34 41 between the MVC layers. 35 42 36 **Note**:43 .. note:: 37 44 38 This method used to use lxml to inject the tags into the html but it now 39 uses regular expressions. This removes the lxml dependency completely. 45 This method used to use `lxml`_ to inject the tags into the html but it now 46 uses regular expressions. These removes this troublesome `C`_ dependency 47 completely. 40 48 41 49 In this tutorial I will only cover the second mechanism. … … 54 62 'toscawidgets.middleware.inject_resources' : True, 55 63 }) 64 65 .. warning:: 66 67 Configuring the middleware like this to inject resources does not play well 68 with cacheing done at Pylons' :func:`render` function. 69 In this scenario it is best to inject resources manually by calling 70 :func:`tw.api.inject_resources` on the HTML string before cacheing it. 71 56 72 57 73 Add your fancy fields to the form … … 93 109 * fielderror 94 110 This class is applied to the divs that display form errors. For example 95 to make errors red colored and bold you would add to your page's CSS:: 111 to make errors red colored and bold you would add to your page's CSS: 112 113 .. code-block:: css 96 114 97 115 .fielderror { … … 101 119 102 120 * fieldhelp 103 This class is applied to the divs that display the fields' `help_text` 104 attribute. For example, to make the fields' help messages smaller in 105 size and lighter in coloryou would add to your page's CSS:: 121 This class is applied to the divs that display the fields' 122 :attr:`FormField.help_text` attribute. 123 For example, to make the fields' help messages smaller in 124 size and lighter in coloryou would add to your page's CSS: 106 125 126 .. code-block:: css 127 107 128 .fieldhelp { 108 129 color: #aaa; … … 112 133 * has_error 113 134 This class is applied to the outermost HTML elements of every 114 :class:` tw.forms.fields.FormField` that has produced an error when135 :class:`FormField` that has produced an error when 115 136 validating. 116 137 For example, to make the fields that have an error have a red 117 background you would add to your page's CSS: :138 background you would add to your page's CSS: 118 139 140 .. code-block:: css 141 119 142 input.has_error, 120 143 select.has_error, … … 123 146 } 124 147 125 Some other classes are produced by specialized :class:`tw.forms.fields.FormField`\ s. The best 126 way to find out all available CSS classes is to use a tool like 148 * required 149 This class is applied to both the input field and its label when the 150 field is a required field. Required fields are found automatically 151 by simulating validation with an empty value. 152 For example, to make required fields' labels be bolder you would add 153 to your page's CSS: 154 155 .. code-block:: css 156 157 label.required { 158 font-weight: bold; 159 } 160 161 Some other classes are produced by specialized :class:`FormField` subclasses. 162 The best way to find out all available CSS classes is to use a tool like 127 163 `Firebug <http://getfirebug.com/>`_ to query each DOM element. 128 164 … … 131 167 132 168 XXX: Write me 169 170 171 .. _lxml: http://codespeak.net/lxml/ 172 .. _blog: http://blog.ianbicking.org/lxml-transformations.html 173 .. _C: http://en.wikipedia.org/wiki/C_(programming_language) projects/ToscaWidgetsForms/trunk/docs/tutorials/tutorial_index.rst
r4540 r4543 5 5 6 6 .. toctree:: 7 :maxdepth: 17 :maxdepth: 2 8 8 9 9 sample_form 10 tg2 10 11 pylons_one 11 12 pylons_two