web/views/autoform.py
changeset 4105 de31c3afe975
parent 4083 3b285889b8e9
child 4110 8728d8c95985
equal deleted inserted replaced
4104:7e478d7caf20 4105:de31c3afe975
    57         called.
    57         called.
    58         """
    58         """
    59         try:
    59         try:
    60             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
    60             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
    61         except form.FieldNotFound:
    61         except form.FieldNotFound:
    62             if eschema is None or not name in cls_or_self._cw.vreg.schema:
    62             if eschema is None or not name in eschema.schema:
    63                 raise
    63                 raise
    64             rschema = cls_or_self._cw.vreg.schema.rschema(name)
    64             rschema = eschema.schema.rschema(name)
    65             # XXX use a sample target type. Document this.
    65             # XXX use a sample target type. Document this.
    66             tschemas = rschema.targets(eschema, role)
    66             tschemas = rschema.targets(eschema, role)
    67             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role,
    67             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role,
    68                                                      tschemas[0])
    68                                                      tschemas[0])
    69             kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema,
    69             kwargs = cls_or_self.rfields_kwargs.etype_get(eschema, rschema,
   348         through the given relation
   348         through the given relation
   349         """
   349         """
   350         yield self._cw.vreg['views'].select('inline-creation', self._cw,
   350         yield self._cw.vreg['views'].select('inline-creation', self._cw,
   351                                             etype=ttype, rtype=rschema, role=role,
   351                                             etype=ttype, rtype=rschema, role=role,
   352                                             peid=self.edited_entity.eid, pform=self)
   352                                             peid=self.edited_entity.eid, pform=self)
   353 
       
   354 
       
   355 def etype_relation_field(etype, rtype, role='subject'):
       
   356     eschema = AutomaticEntityForm.schema.eschema(etype)
       
   357     return AutomaticEntityForm.field_by_name(rtype, role, eschema)
       
   358 
   353 
   359 
   354 
   360 ## default form ui configuration ##############################################
   355 ## default form ui configuration ##############################################
   361 
   356 
   362 _afs = uicfg.autoform_section
   357 _afs = uicfg.autoform_section
   404                                           {'widget': fwdgs.TextInput})
   399                                           {'widget': fwdgs.TextInput})
   405 uicfg.autoform_field_kwargs.tag_attribute(('Bookmark', 'path'),
   400 uicfg.autoform_field_kwargs.tag_attribute(('Bookmark', 'path'),
   406                                           {'widget': fwdgs.TextInput})
   401                                           {'widget': fwdgs.TextInput})
   407 uicfg.autoform_field_kwargs.tag_subject_of(('TrInfo', 'wf_info_for', '*'),
   402 uicfg.autoform_field_kwargs.tag_subject_of(('TrInfo', 'wf_info_for', '*'),
   408                                            {'widget': fwdgs.HiddenInput})
   403                                            {'widget': fwdgs.HiddenInput})
       
   404 
       
   405 def registration_callback(vreg):
       
   406     global etype_relation_field
       
   407 
       
   408     def etype_relation_field(etype, rtype, role='subject'):
       
   409         eschema = vreg.schema.eschema(etype)
       
   410         return AutomaticEntityForm.field_by_name(rtype, role, eschema)