web/views/autoform.py
branchtls-sprint
changeset 1743 591cff8f0701
parent 1739 78b0819162a8
child 1752 4b0b912ff5b7
equal deleted inserted replaced
1742:25a765e756c4 1743:591cff8f0701
   143             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
   143             return super(AutomaticEntityForm, cls_or_self).field_by_name(name, role)
   144         except FieldNotFound: # XXX should raise more explicit exception
   144         except FieldNotFound: # XXX should raise more explicit exception
   145             if eschema is None or not name in cls_or_self.schema:
   145             if eschema is None or not name in cls_or_self.schema:
   146                 raise
   146                 raise
   147             rschema = cls_or_self.schema.rschema(name)
   147             rschema = cls_or_self.schema.rschema(name)
   148             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role)
   148             # XXX use a sample target type. Document this.
       
   149             tschemas = rschema.targets(eschema, role)
       
   150             fieldcls = cls_or_self.rfields.etype_get(eschema, rschema, role, tschemas[0])
   149             if fieldcls:
   151             if fieldcls:
   150                 return fieldcls(name=name, role=role, eidparam=True)
   152                 return fieldcls(name=name, role=role, eidparam=True)
   151             widget = cls_or_self.rwidgets.etype_get(eschema, rschema, role)
   153             widget = cls_or_self.rwidgets.etype_get(eschema, rschema, role, tschemas[0])
   152             if widget:
   154             if widget:
   153                 field = guess_field(eschema, rschema, role,
   155                 field = guess_field(eschema, rschema, role,
   154                                     eidparam=True, widget=widget)
   156                                     eidparam=True, widget=widget)
   155             else:
   157             else:
   156                 field = guess_field(eschema, rschema, role, eidparam=True)
   158                 field = guess_field(eschema, rschema, role, eidparam=True)