18 from cubicweb.web.controller import NAV_FORM_PARAMETERS |
18 from cubicweb.web.controller import NAV_FORM_PARAMETERS |
19 from cubicweb.web.formfields import HiddenInitialValueField, StringField |
19 from cubicweb.web.formfields import HiddenInitialValueField, StringField |
20 |
20 |
21 |
21 |
22 class FieldsForm(form.Form): |
22 class FieldsForm(form.Form): |
|
23 """base class for fields based forms. |
|
24 |
|
25 The following attributes may be either set on subclasses or given on |
|
26 form selection to customize the generated form: |
|
27 |
|
28 * `needs_js`: sequence of javascript files that should be added to handle |
|
29 this form (through `req.add_js`) |
|
30 |
|
31 * `needs_css`: sequence of css files that should be added to handle this |
|
32 form (through `req.add_css`) |
|
33 |
|
34 * `domid`: value for the "id" attribute of the <form> tag |
|
35 |
|
36 * `action`: value for the "action" attribute of the <form> tag |
|
37 |
|
38 * `onsubmit`: value for the "onsubmit" attribute of the <form> tag |
|
39 |
|
40 * `cssclass`: value for the "class" attribute of the <form> tag |
|
41 |
|
42 * `cssstyle`: value for the "style" attribute of the <form> tag |
|
43 |
|
44 * `cwtarget`: value for the "cubicweb:target" attribute of the <form> tag |
|
45 |
|
46 * `redirect_path`: relative to redirect to after submitting the form |
|
47 |
|
48 * `copy_nav_params`: flag telling if navigation paramenters should be copied |
|
49 back in hidden input |
|
50 |
|
51 * `form_buttons`: form buttons sequence (button widgets instances) |
|
52 |
|
53 * `form_renderer_id`: id of the form renderer to use to render the form |
|
54 |
|
55 * `fieldsets_in_order`: fieldset name sequence, to control order |
|
56 """ |
23 id = 'base' |
57 id = 'base' |
24 |
58 |
25 is_subform = False |
59 is_subform = False |
26 |
|
27 # attributes overrideable through __init__ |
|
28 internal_fields = ('__errorurl',) + NAV_FORM_PARAMETERS |
60 internal_fields = ('__errorurl',) + NAV_FORM_PARAMETERS |
|
61 |
|
62 # attributes overrideable by subclasses or through __init__ |
29 needs_js = ('cubicweb.ajax.js', 'cubicweb.edition.js',) |
63 needs_js = ('cubicweb.ajax.js', 'cubicweb.edition.js',) |
30 needs_css = ('cubicweb.form.css',) |
64 needs_css = ('cubicweb.form.css',) |
31 domid = 'form' |
65 domid = 'form' |
32 title = None |
|
33 action = None |
66 action = None |
34 onsubmit = "return freezeFormButtons('%(domid)s');" |
67 onsubmit = "return freezeFormButtons('%(domid)s');" |
35 cssclass = None |
68 cssclass = None |
36 cssstyle = None |
69 cssstyle = None |
37 cwtarget = None |
70 cwtarget = None |
38 redirect_path = None |
71 redirect_path = None |
39 copy_nav_params = False |
72 copy_nav_params = False |
40 form_buttons = None # form buttons (button widgets instances) |
73 form_buttons = None |
41 form_renderer_id = 'default' |
74 form_renderer_id = 'default' |
|
75 fieldsets_in_order = None |
42 |
76 |
43 def __init__(self, req, rset=None, row=None, col=None, |
77 def __init__(self, req, rset=None, row=None, col=None, |
44 submitmsg=None, mainform=True, |
78 submitmsg=None, mainform=True, |
45 **kwargs): |
79 **kwargs): |
46 super(FieldsForm, self).__init__(req, rset, row=row, col=col) |
80 super(FieldsForm, self).__init__(req, rset, row=row, col=col) |