Ok, I think I've found the problem. If we assume a test using a
TextField as the widget to be cloned, the html produced is like this:

<div id="ajaxcompound_4_AjaxRepeating_template" class="invisible">
     <input type="text"
            id="ajax_repeater_form_customFieldsRepeater_customFields"
            value="" class="textfield"
            name="customFieldsRepeater.customFields"/>
</div>
<div id="ajaxcompound_4_AjaxRepeating_rep_0">
     <label
for="ajax_repeater_form_customFieldsRepeater_0_customFields"
            class="fieldlabel">Customfields</label>
     <span>
          <input type="text" name="customFieldsRepeater-0.customFields"
                 class="textfield"

id="ajax_repeater_form_customFieldsRepeater_0_customFields"/>
     </span>
</div>
<div id="ajaxcompound_4_AjaxRepeating_container">
</div>

As soon as the user adds a new field, the javascript inserts the
following div inside the container:

<div id="ajaxcompound_4_AjaxRepeating_element_0" class="">
     <input type="text"
            id="ajax_repeater_form_customFieldsRepeater_customFields"
            value="" class="textfield"
            name="customFieldsRepeater.customFields"/>
</div>

Since the widget is supposed to be agnostic as to what is cloned, I
just create the div, give it a diferent id, and slip inside a clone of
the template.

Now, when we post the form containing these fields with value1 on the
first text box which was created by repetition, and value2 on the
second text box, which was created by javascript, firefox sends:

customFieldsRepeater.customFields=
customFieldsRepeater-0.customFields=value1
customFieldsRepeater.customFields=value2

which on turbogears/cherrypy by the time the form is being validated
(widgets/forms.py:1073) gets translated the following value for the
customFieldsRepeater key on the validation value:

[{'customFields': u'value1'}, [u'', u'value2']]

And here's the catch.  For the repeating widget a dictionary is
created. For the javascript cloned entries, a list is created.
I've iet to investigate further as to how to get around this.
My first thought is to try and associate a validator to this widget
which does the translation correctly, but I'm not sure how it would
behave on cases were there are more than one cloned widget.

Has someone had any previous experience doing any of the above? Or any
ideia as to how it would better be implemented? I'm thinking of just
putting this widget up on the cheeseshop if it ends up any good, to
try and contribute something to the whole :)


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"TurboGears" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/turbogears
-~----------~----~----~----~------~----~------~--~---

Reply via email to