'Return FormDefinition created from an xml element.'

def from_elem(self, elem, form_definition_current=None):

    name = elem.get('name', None)
    description = elem.get('description', None)
    form_type = elem.get('type', None)
    layout = []
    layouts_elem = elem.find('layout')
    if layouts_elem:
        for layout_elem in layouts_elem.findall('grid'):
            layout_name = layout_elem.get('name', None)
            assert (layout_name and (layout_name not in layout)), 'Layout    grid    element    requires    a    unique    name.'
            layout.append(layout_name)
    fields = []
    fields_elem = elem.find('fields')
    if (fields_elem is not None):
        for field_elem in fields_elem.findall('field'):
            field_type = field_elem.get('type')
            assert (field_type in self.field_type_factories), ('Invalid    form    field    type    (    %s    ).' % field_type)
            fields.append(self.field_type_factories[field_type].from_elem(field_elem, layout))
    return self.new(form_type, name, description=description, fields=fields, layout=layout, form_definition_current=form_definition_current)
