@@ -100,8 +100,8 @@ Where:
100100- ``readonly ``: set to True to make a readonly form
101101- ``deletable ``: set to False to disallow deletion of record
102102- ``formstyle ``: a function that renders the form using helpers.
103- Can be FormStyleDefault (default), FormStyleBulma,
104- FormStyleBootstrap4, or FormStyleBootstrap5
103+ Can be `` FormStyleDefault `` (default), `` FormStyleBulma `` ,
104+ `` FormStyleBootstrap4 `` , or `` FormStyleBootstrap5 ``.
105105- ``dbio ``: set to False to prevent any DB writes
106106- ``keep_values ``: if set to true, it remembers the values of the previously submitted form
107107- ``form_name ``: the optional name of this form
@@ -111,6 +111,13 @@ Where:
111111- ``lifespan ``: lifespan of CSRF token in seconds, to limit form validity
112112- ``signing_info ``: information that should not change between when the CSRF token is signed and verified
113113
114+ ``FormStyleDefault `` is an object that is used by default for every form
115+ and it is defined in ``py4web.utils.form.FormStyleDefault ``.
116+ You should never change it but you can make a copy and pass it as ``formstyle ``.
117+
118+ You can change the style of a field named, for example, ``color ``
119+ by changing the attribute ``color `` of the FormStyle.
120+
114121
115122A minimal form example without a database
116123-----------------------------------------
@@ -352,8 +359,8 @@ Using widgets in forms is quite easy, and they'll let you have more control on i
352359Custom widgets
353360~~~~~~~~~~~~~~
354361
355- You can also customize the widgets properties by subclassing the FormStyleDefault class. Let's have a quick look,
356- improving again our Superhero example:
362+ You can also customize the widgets properties by cloning an modifying and existing style.
363+ Let's have a quick look, improving again our Superhero example:
357364
358365.. code :: python
359366
@@ -383,7 +390,7 @@ improving again our Superhero example:
383390 @action (" create_form" , method = [" GET" , " POST" ])
384391 @action.uses (" form_custom_widgets.html" , db)
385392 def create_form ():
386- MyStyle = FormStyleDefault
393+ MyStyle = FormStyleDefault.clone()
387394 MyStyle.classes = FormStyleDefault.classes
388395 MyStyle.widgets[' name' ]= MyCustomWidget()
389396 MyStyle.widgets[' color' ]= RadioWidget()
0 commit comments