How to use the coderedcms.wagtail_flexible_forms.models.Steps function in coderedcms

To help you get started, we’ve selected a few coderedcms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github coderedcorp / coderedcms / coderedcms / wagtail_flexible_forms / models.py View on Github external
def get_steps(self, request=None):
        if not hasattr(self, 'steps'):
            steps = Steps(self, request=request)
            if request is None:
                return steps
            self.steps = steps
        return self.steps
github coderedcorp / coderedcms / coderedcms / models / page_models.py View on Github external
class CoderedStep(Step):

    def get_markups_and_bound_fields(self, form):
        for struct_child in self.form_fields:
            block = struct_child.block
            if isinstance(block, FormFieldBlock):
                struct_value = struct_child.value
                field_name = block.get_slug(struct_value)
                yield form[field_name], 'field', struct_child
            else:
                yield mark_safe(struct_child), 'markup'


class CoderedSteps(Steps):

    def __init__(self, page, request=None):
        self.page = page
        # TODO: Make it possible to change the `form_fields` attribute.
        self.form_fields = page.form_fields
        self.request = request
        has_steps = any(isinstance(struct_child.block, FormStepBlock)
                        for struct_child in self.form_fields)
        if has_steps:
            steps = [CoderedStep(self, i, form_field)
                     for i, form_field in enumerate(self.form_fields)]
        else:
            steps = [CoderedStep(self, 0, self.form_fields)]
        super(Steps, self).__init__(steps)
github coderedcorp / coderedcms / coderedcms / models / page_models.py View on Github external
def __init__(self, page, request=None):
        self.page = page
        # TODO: Make it possible to change the `form_fields` attribute.
        self.form_fields = page.form_fields
        self.request = request
        has_steps = any(isinstance(struct_child.block, FormStepBlock)
                        for struct_child in self.form_fields)
        if has_steps:
            steps = [CoderedStep(self, i, form_field)
                     for i, form_field in enumerate(self.form_fields)]
        else:
            steps = [CoderedStep(self, 0, self.form_fields)]
        super(Steps, self).__init__(steps)