def _widget_create(self, r, **attr):
        """
            Create-buttons/form in summary views, both GET and POST

            @param r: the S3Request
            @param attr: dictionary of parameters for the method handler
        """

        response = current.response

        resource = self.resource
        get_config = resource.get_config
        tablename = resource.tablename

        output = {}
        insertable = get_config("insertable", True)
        if insertable:

            listadd = get_config("listadd", True)
            addbtn = get_config("addbtn", False)

            if listadd:
                # Hidden form + Add-button to activate it
                self.data = None
                if r.http == "GET" and not self.record_id:
                    populate = attr.pop("populate", None)
                    if callable(populate):
                        try:
                            self.data = populate(r, **attr)
                        except __HOLE__:
                            self.data = None
                        except:
                            raise
                    elif isinstance(populate, dict):
                        self.data = populate

                view = response.view

                # JS Cancel (no redirect with embedded form)
                s3 = response.s3
                cancel = s3.cancel
                s3.cancel = {"hide": "list-add", "show": "show-add-btn"}

                form = self.create(r, **attr).get("form", None)
                if form and form.accepted and self.next:
                    # Tell the summary handler that we're done
                    # and supposed to redirect to another view
                    return {"success": True, "next": self.next}

                # Restore standard view and cancel-config
                response.view = view
                s3.cancel = cancel

                if form is not None:
                    output["form"] = form
                    output["showadd_btn"] = self.crud_button(tablename=tablename,
                                                             name="label_create",
                                                             icon="add",
                                                             _id="show-add-btn")
                    addtitle = self.crud_string(tablename, "label_create")
                    output["addtitle"] = addtitle
                    if r.http == "POST":
                        # Always show the form if there was a form error
                        script = '''$('#list-add').show();$('#show-add-btn').hide()'''
                        s3.jquery_ready.append(script)

                    # Add-button script
                    # - now in S3.js
                    #script = '''$('#show-add-btn').click(function(){$('#show-add-btn').hide(10, function(){$('#list-add').slideDown('medium')})})'''
                    #s3.jquery_ready.append(script)

            elif addbtn:
                # No form, just Add-button linked to create-view
                add_btn = self.crud_button(
                                    tablename=tablename,
                                    name="label_create",
                                    icon="add",
                                    _id="add-btn")
                output["buttons"] = {"add_btn": add_btn}

        view = self._view(r, "listadd.html")
        output = XML(response.render(view, output))
        return output

    # -------------------------------------------------------------------------
dataset/ETHPy150Open sahana/eden/modules/s3/s3crud.py/S3CRUD._widget_create