Ejemplo n.º 1
0
    def get_form(self, request, form_class=None, instance=None,
                 addinputs=True, **kwargs):
        '''Build a form. This method is called by editing/adding views.

:parameter form_class: form class to use.
:parameter instance: Instance of model or ``None`` or ``False``. If ``False``
    no instance will be passed to the form constructor.
    If ``None`` the instance will be obtained from '`request``.

    Default ``None``.

:parameter block: The content block holding the form.

:rtype: An instance of :class:`djpcms.forms.Form`.
'''
        # Check the Form Class
        form_class = form_class or self.form
        if not form_class:
            raise ValueError('Form class not defined for view "{0}" in\
 application "{1}" @ "{2}".\
 Make sure to pass a class form to the view or application constructor.'\
                    .format(request.view,self.__class__.__name__,self))
        elif isinstance(form_class, forms.FormType):
            form_class = forms.HtmlForm(form_class)
        # Check instance and model
        if instance == False:
            instance = None
        else:
            instance = instance or request.instance
        return get_form(request,
                        form_class,
                        instance=instance,
                        model=self.model,
                        addinputs=addinputs,
                        **kwargs)
Ejemplo n.º 2
0
    def get_form(self,
                 request,
                 form_class=None,
                 instance=None,
                 addinputs=True,
                 **kwargs):
        '''Build a form. This method is called by editing/adding views.

:parameter form_class: form class to use.
:parameter instance: Instance of model or ``None`` or ``False``. If ``False``
    no instance will be passed to the form constructor.
    If ``None`` the instance will be obtained from '`request``.

    Default ``None``.

:parameter block: The content block holding the form.

:rtype: An instance of :class:`djpcms.forms.Form`.
'''
        # Check the Form Class
        form_class = form_class or self.form
        if not form_class:
            raise ValueError('Form class not defined for view "{0}" in\
 application "{1}" @ "{2}".\
 Make sure to pass a class form to the view or application constructor.'\
                    .format(request.view,self.__class__.__name__,self))
        elif isinstance(form_class, forms.FormType):
            form_class = forms.HtmlForm(form_class)
        # Check instance and model
        if instance == False:
            instance = None
        else:
            instance = instance or request.instance
        return get_form(request,
                        form_class,
                        instance=instance,
                        model=self.model,
                        addinputs=addinputs,
                        **kwargs)
Ejemplo n.º 3
0
 def render_instance_default(self, request, instance, **kwargs):
     return get_form(request, ThemeInputsHtml)
Ejemplo n.º 4
0
 def render_instance_default(self, request, instance, **kwargs):
     return get_form(request, ThemeInputsHtml)