web/formfields.py
branchstable
changeset 2095 897732d3ee5a
parent 2091 a7ea618e5478
child 2146 6645e18e8c93
equal deleted inserted replaced
2094:59a4e9f4f57a 2095:897732d3ee5a
   453         targetschema = rschema.objects(eschema)[0]
   453         targetschema = rschema.objects(eschema)[0]
   454         card = rschema.rproperty(eschema, targetschema, 'cardinality')[0]
   454         card = rschema.rproperty(eschema, targetschema, 'cardinality')[0]
   455         help = rschema.rproperty(eschema, targetschema, 'description')
   455         help = rschema.rproperty(eschema, targetschema, 'description')
   456         if rschema.is_final():
   456         if rschema.is_final():
   457             if rschema.rproperty(eschema, targetschema, 'internationalizable'):
   457             if rschema.rproperty(eschema, targetschema, 'internationalizable'):
   458                 kwargs['internationalizable'] = True
   458                 kwargs.setdefault('internationalizable', True)
   459             def get_default(form, es=eschema, rs=rschema):
   459             def get_default(form, es=eschema, rs=rschema):
   460                 return es.default(rs)
   460                 return es.default(rs)
   461             kwargs['initial'] = get_default
   461             kwargs.setdefault('initial', get_default)
   462     else:
   462     else:
   463         targetschema = rschema.subjects(eschema)[0]
   463         targetschema = rschema.subjects(eschema)[0]
   464         card = rschema.rproperty(targetschema, eschema, 'cardinality')[1]
   464         card = rschema.rproperty(targetschema, eschema, 'cardinality')[1]
   465         help = rschema.rproperty(targetschema, eschema, 'description')
   465         help = rschema.rproperty(targetschema, eschema, 'description')
   466     kwargs['required'] = card in '1+'
   466     kwargs['required'] = card in '1+'
   467     kwargs['name'] = rschema.type
   467     kwargs['name'] = rschema.type
   468     kwargs['help'] = help
   468     kwargs.setdefault('help', help)
   469     if rschema.is_final():
   469     if rschema.is_final():
   470         if skip_meta_attr and rschema in eschema.meta_attributes():
   470         if skip_meta_attr and rschema in eschema.meta_attributes():
   471             return None
   471             return None
   472         fieldclass = FIELDS[targetschema]
   472         fieldclass = FIELDS[targetschema]
   473         if fieldclass is StringField:
   473         if fieldclass is StringField: