python类HiddenField()的实例源码

forms.py 文件源码 项目:pillar 作者: armadillica 项目源码 文件源码 阅读 26 收藏 0 点赞 0 评论 0
def get_node_form(node_type):
    """Get a procedurally generated WTForm, based on the dyn_schema and
    node_schema of a specific node_type.
    :type node_type: dict
    :param node_type: Describes the node type via dyn_schema, form_schema and
    parent
    """
    class ProceduralForm(Form):
        pass

    parent_prop = node_type['parent']

    ProceduralForm.name = StringField('Name', validators=[DataRequired()])
    # Parenting
    if parent_prop:
        parent_names = ", ".join(parent_prop)
        ProceduralForm.parent = HiddenField('Parent ({0})'.format(parent_names))

    ProceduralForm.description = TextAreaField('Description')
    ProceduralForm.picture = FileSelectField('Picture', file_format='image')
    ProceduralForm.node_type = HiddenField(default=node_type['name'])

    add_form_properties(ProceduralForm, node_type)

    return ProceduralForm()


问题


面经


文章

微信
公众号

扫码关注公众号