equal
deleted
inserted
replaced
17 match_user_groups) |
17 match_user_groups) |
18 from cubicweb.view import StartupView |
18 from cubicweb.view import StartupView |
19 from cubicweb.web import uicfg, stdmsgs |
19 from cubicweb.web import uicfg, stdmsgs |
20 from cubicweb.web.form import FormViewMixIn |
20 from cubicweb.web.form import FormViewMixIn |
21 from cubicweb.web.formfields import FIELDS, StringField |
21 from cubicweb.web.formfields import FIELDS, StringField |
22 from cubicweb.web.formwidgets import Select, Button, SubmitButton |
22 from cubicweb.web.formwidgets import Select, TextInput, Button, SubmitButton |
23 from cubicweb.web.views import primary, formrenderers |
23 from cubicweb.web.views import primary, formrenderers |
24 |
24 |
25 |
25 |
26 # some string we want to be internationalizable for nicer display of property |
26 # some string we want to be internationalizable for nicer display of property |
27 # groups |
27 # groups |
344 # list() just in case its a generator function |
344 # list() just in case its a generator function |
345 self.choices = list(vocab(form.req)) |
345 self.choices = list(vocab(form.req)) |
346 else: |
346 else: |
347 self.choices = vocab |
347 self.choices = vocab |
348 wdg = Select() |
348 wdg = Select() |
|
349 elif pdef['type'] == 'String': # else we'll get a TextArea by default |
|
350 wdg = TextInput() |
349 else: |
351 else: |
350 wdg = FIELDS[pdef['type']].widget() |
352 field = FIELDS[pdef['type']]() |
|
353 wdg = field.widget |
351 if pdef['type'] == 'Boolean': |
354 if pdef['type'] == 'Boolean': |
352 self.choices = [(form.req._('yes'), '1'), (form.req._('no'), '')] |
355 self.choices = field.vocabulary(form) |
353 elif pdef['type'] in ('Float', 'Int'): |
|
354 wdg.attrs.setdefault('size', 3) |
|
355 self.widget = wdg |
356 self.widget = wdg |
356 |
357 |
357 |
358 |
358 uicfg.autoform_field.tag_attribute(('CWProperty', 'pkey'), PropertyKeyField) |
359 uicfg.autoform_field.tag_attribute(('CWProperty', 'pkey'), PropertyKeyField) |
359 uicfg.autoform_field.tag_attribute(('CWProperty', 'value'), PropertyValueField) |
360 uicfg.autoform_field.tag_attribute(('CWProperty', 'value'), PropertyValueField) |