# from {{{ package.dottedname }}} import _
from plone import schema
from plone.autoform.form import AutoExtensibleForm
from z3c.form import button
from z3c.form import form
from zope.interface import Interface


class I{{{ form_python_class_name }}}(Interface):
    """ Schema Interface for I{{{ form_python_class_name }}}
        Define your form fields here.
    """
    name = schema.TextLine(
        title=u"Your name",
    )


class {{{ form_python_class_name }}}(AutoExtensibleForm, form.EditForm):
    schema = I{{{ form_python_class_name }}}
    ignoreContext = True

    label = u"What's your name?"
    description = u"Simple, sample form"

    @button.buttonAndHandler(u'Ok')
    def handleApply(self, action):
        data, errors = self.extractData()
        if errors:
            self.status = self.formErrorsMessage
            return

        # Do something with valid data here

        changes = self.applyChanges(data)
        # Set status on this form page
        # (this status message is not bind to the session and does not go thru redirects)
        if changes:
            self.status = "Settings saved"

    @button.buttonAndHandler(u"Cancel")
    def handleCancel(self, action):
        """User canceled. Redirect back to the front page.
        """
