[Webware] FormKit - dynamic fields problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JZ

    [Webware] FormKit - dynamic fields problem

    I use Webware and FormKit. I have a problem with dynamic added field
    to the form. The following code creates one input field and two submit
    buttons. I would like to add more (up to 4) input fields after
    pressing "more" button. It does not work and I have no idea how to
    solve it.

    import re
    from WebKit.Page import Page
    from FormKit import Form, Fields, Validators
    from FormKit.FormKit MixIn import FormKitMixIn

    class DynamicProblem( FormKitMixIn, Page):

    def __init__(self):
    Page.__init__(s elf)
    notEmpty = Validators.NotE mpty()
    f = self.form = Form.Form()
    self.addForm(f)
    f.addField(Fiel ds.TextField('m sg', validators=[notEmpty]))
    f.addField(Fiel ds.WebKitSubmit Button('more'))
    f.addField(Fiel ds.WebKitSubmit Button('send'))

    def sleep(self, trans):
    self.resetForms ()
    Page.sleep(self , trans)

    def writeHTML(self) :
    self.write(self .form.dump())

    def extendForm(self ):
    notEmpty = Validators.NotE mpty()
    f = self.form
    nr = len(filter(lamb da x:re.match(r'^m sg',x),
    self.form.value s().keys()))
    if nr < 4:
    f.addField(Fiel ds.TextField('m sg%d' % nr,
    validators=[notEmpty]))

    def actions(self):
    return ['more', 'send']

    def more(self):
    if self.form.isSuc cessful():
    self.extendForm ()

    def send(self):
    if self.form.isSuc cessful():
    pass

    --
    JZ

  • Joe Francia

    #2
    Re: [Webware] FormKit - dynamic fields problem

    JZ wrote:[color=blue]
    > I use Webware and FormKit. I have a problem with dynamic added field
    > to the form. The following code creates one input field and two submit
    > buttons. I would like to add more (up to 4) input fields after
    > pressing "more" button. It does not work and I have no idea how to
    > solve it.
    >[/color]

    You also may want to post this question to the WebWare list, if you
    haven't already:
    Free, secure and fast downloads from the largest Open Source applications and software directory - SourceForge.net


    If you don't want to join yet another mailing lists, you can access the
    WebWare list in your newsreader by pointing it to news.gmane.org and
    subscribing to gmane.comp.pyth on.webware.

    Comment

    Working...