Really this is my first attempt at using these technologies in web
development at all, so please bear with me if i sound like an idiot =]

I have a page that has two RemoteForms, and a table form with the
turbotinymce widget in it.  The first RemoteForm sections_form has a
select box in it that when submitted i want it to update the options
for the select boxes in the second RemoteForm constants_form.  This is
working fine (although i don't know if my methods of rendering the form
and sending the string to the template are the right way of doing it),
what fails is when i submit the second RemoteForm data (constants_form)
to the third form (TableForm) translate_form, the data all populates in
the textarea's correctly but the TinyMCE "formated" textarea that was
there in the previous two steps changes to a normal textarea field.

So is there a flaw in my methodology in TG here, or is this something i
should take up with the TinyMCE folks?


And for the sake of completeness, here is my template and controller
file...

-----edit.kid-----
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd";>
<html xmlns="http://www.w3.org/1999/xhtml";
xmlns:py="http://purl.org/kid/ns#";
    py:extends="'master.kid'">
  <head>
    <meta content="text/html; charset=UTF-8" http-equiv="content-type"
py:replace="''"/>
    <title>Make a translation</title>
  </head>
        <body>
                <div id="sections_data">${sections_form.display()}</div>
                <div id="constants_data">${constants_form.display()}</div>
                <div id="translation_data">${translate_form.display()}</div>
        </body>
</html>

------controllers.py------
import turbogears
from turbogears import controllers, expose, validate, redirect,
error_handler, widgets, validators
from turbogears.toolbox.catwalk import CatWalk
from tinymce import TinyMCE

import model
from model import *
#from localizer import json

class SectionFormFields(widgets.WidgetsList):
    section =
widgets.SingleSelectField(validator=validators.NotEmpty(),
                                        options=Section.section_list)
sections_form = widgets.RemoteForm(fields = SectionFormFields(),
                                    name="sections_form",
                                    update = "constants_data",
                                    action = "/load_sections",
                                    submit_text = "Load Section")

class ConstantsFormFields(widgets.WidgetsList):
    constant =
widgets.SingleSelectField(validator=validators.NotEmpty())
    localization =
widgets.SingleSelectField(validator=validators.NotEmpty())
constants_form = widgets.RemoteForm(fields = ConstantsFormFields(),
                                    name="constants_form",
                                    update = "translation_data",
                                    action = "/load_translation",
                                    submit_text = "Load Translation")

class TranslationFields(widgets.WidgetsList):
    constant_id = widgets.HiddenField()
    localization_id = widgets.HiddenField()
    english_text = widgets.TextArea(label="English Text",
                                    validator=validators.NotEmpty())
    translated_text = TinyMCE(label="Translation")
translate_form = widgets.TableForm(fields=TranslationFields(),
                                    action="save_translation",
                                    submit_text="Save Translation")

class Root(controllers.RootController):
    catwalk = CatWalk(model)

    @expose(template="localizer.templates.edit")
    def index(self):
        return dict(sections_form=sections_form,
                    constants_form=constants_form,
                    translate_form=translate_form)

    @expose()
    def load_sections(self, **data):
        constants = Constant.bySection_list(data['section'])
        localizations = Localization.localization_list()
        form = constants_form.render(options=dict(constant=constants,

localization=localizations))
        return str(form)

    @expose()
    def load_translation(self, **data):
        constant = Constant.get(data['constant'])
        translated_text = TranslatedData.select(AND(
                                        TranslatedData.q.constantID ==
data['constant'],
                                        TranslatedData.q.loc_keyID ==
data['localization']))
        form = translate_form.render(value=dict(
                                        english_text=constant.text,

translated_text=translated_text,
                                        constant_id = constant.id,
                                        localization_id =
data['localization']))
        return str(form)

    @expose
    def save_translation(self, **data):
        #nothing here yet, need to get the other stuff working first.
        pass


--~--~---------~--~----~------------~-------~--~----~
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