[Kss-devel] Problems with kssSubmitForm , changing value of all "input"-tags after select:change?

Godefroid Chapelle gotcha at bubblenet.be
Mon Jun 4 23:04:52 CEST 2007


Nylan at gmx.net wrote:
> Hello, 
> 
> I'm having some problems with kssSubmitForm, but the demo works without problems.
> 
> Use-case:
> There is one "select"-tag in forms.pt with a vocabulary based choice (data fetched from database)
> On "select:change" I would like to change the attribute "value" of all "input"-tags as well.(value fetched again from sql database)
> My aim is to initialise input tags with data from templates("select"-Tag)
> 
> 
> So my first idea was kssSubmitForm (dictionary of all input fields)  --> doesn't work at all (see below)
> and to use setAttribute somehow.  :-)
> 
> It was my first idea, so if there is a shorter way please don't mind telling me.
> 
> Thanks.
> 
> Best regards!
> 
> Harald
> 
>

Quick comment, I'd go with simple stuff. I'd replace the whole form 
instead of trying to fine tune... value attributes.

> 
> error with kssSubmitForm:
> ---------------------------------------------------------------------------------------------------------------
> 2007-06-04T20:52:52 ERROR SiteError http://192.168.0.64:8080/dsdsd/submitFullForm
> Traceback (most recent call last):
>   File "/usr/lib64/zope-3.3.1/lib/python/zope/publisher/publish.py", line 133, in publish
>     result = publication.callObject(request, obj)
>   File "/usr/lib64/zope-3.3.1/lib/python/zope/app/publication/zopepublication.py", line 161, in callObject
>     return mapply(ob, request.getPositionalArguments(), request)
>   File "/usr/lib64/zope-3.3.1/lib/python/zope/publisher/publish.py", line 99, in mapply
>     raise TypeError('Missing argument to %s(): %s' % (
>    - __traceback_info__: <bound method DemoView.wrapper of <zope.app.publisher.browser.viewmeta.DemoView object at 0x2c78b10>>
> ---------------------------------------------------------------------------------------------------------------
> 
> 
> form.kss
> ---------------------------------------------------------------------------------------------------------------
> select:change {
>         action-server: submitFullForm;
>         submitFullForm-kssSubmitForm: 'source';
> }
> ---------------------------------------------------------------------------------------------------------------
> 
> 
> demoview.py
> ---------------------------------------------------------------------------------------------------------------
> from kss.core import KSSView ,kssaction
> from datetime import datetime
> 
> class DemoView(KSSView):
> 
>     @kssaction
>     def submitFullForm(self, form):
>         assert hasattr(form, 'keys'), 'Form data is expected to be a dict-like object.'
>         # marshall back the repr of this dict.
>         ksscore = self.getCommandSet('core')
>         ksscore.replaceInnerHTML('#target', repr(form))
> ---------------------------------------------------------------------------------------------------------------
> 
> 
> forms.pt
> ---------------------------------------------------------------------------------------------------------------
> <html xmlns="http://www.w3.org/1999/xhtml"
>       xmlns:tal="http://xml.zope.org/namespaces/tal"
>       xmlns:metal="http://xml.zope.org/namespaces/metal" 
>       >
> <head>
>         <link rel="kinetic-stylesheet" type="text/css"
>                   tal:attributes="href string:${context/@@absolute_url}/++resource++form.kss"/>
>         <metal:header use-macro="context/@@header_macros/header_resources" />                     
> 
> </head>
> <body>
> <div metal:use-macro="context/@@standard_macros/view">
>         <div metal:fill-slot="body">
>                 <p><a href="javascript:void(createLoggingPane(true))">Start logging pane</a></p>
>                 <form name="source" class="edit-form" enctype="multipart/form-data" method="post"
>                       action="." tal:attributes="action request/URL">
> 
>                         <h1 tal:content="view/label" i18n:translate="" >Edit something</h1>
>                         <div class="summary" tal:condition="view/status"
>                                tal:content="view/status">Status</div>
> 
>                         <div class="row" tal:repeat="widget view/widgets">
>                                 <span tal:condition="repeat/widget/odd">
>                                 <div class="label">
>                                         <label for="field.name" title="The widget's hint"
>                                                 tal:attributes="for widget/name; title widget/hint"
>                                                 tal:content="widget/label"  i18n:translate=""
>                                                 i18n:attributes="title">Label</label>
>                                 </div>
>                                 </span>
> 
>                                 <div tal:condition="widget/error"
>                                         tal:content="structure widget/error">Error</div>
>                                 <div class="field">
>                                         <input tal:replace="structure widget"/>
>                                 </div>
>                         </div>
> 
>                         <span class="actionButtons" tal:condition="view/availableActions">
>                         <input tal:repeat="action view/actions"
>                                 tal:replace="structure action/render"
>                         />
>                         </span>
> 
>                 </form>
>         </div>
> </div>
> <div id="target"> Target</div>
> </body>
> </html
> ---------------------------------------------------------------------------------------------------------------
> 
> 
> 
> _______________________________________________
> Kss-devel mailing list
> Kss-devel at codespeak.net
> http://codespeak.net/mailman/listinfo/kss-devel


-- 
Godefroid Chapelle (aka __gotcha)- BubbleNet  http://bubblenet.be



More information about the Kss-devel mailing list