From 2465b23aef9b27af9d4423efbac88c303355ca33 Mon Sep 17 00:00:00 2001 From: Michael Ziegler Date: Fri, 23 Jul 2010 11:32:19 +0200 Subject: [PATCH] properly implement loading/submitting forms via the "pk" option. --- pyweb/extdirect.py | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/pyweb/extdirect.py b/pyweb/extdirect.py index 4baaf26..66c4680 100644 --- a/pyweb/extdirect.py +++ b/pyweb/extdirect.py @@ -53,16 +53,26 @@ Ext.ux.%(clsname)s = function( config ){ this.form.api = %(apiconf)s; this.form.paramsAsHash = true; + + if( typeof config.pk != "undefined" ){ + this.load(); + } } -Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, {} ); +Ext.extend( Ext.ux.%(clsname)s, Ext.form.FormPanel, { + load: function(){ + this.getForm().load({ params: {pk: this.pk} }); + }, + submit: function(){ + this.getForm().submit({ params: {pk: this.pk} }); + }, +} ); Ext.reg( '%(clslowername)s', Ext.ux.%(clsname)s ); """ # About the this.form.* lines, see # http://www.sencha.com/forum/showthread.php?96001-solved-Ext.Direct-load-data-in-extended-Form-fails-%28scope-issue%29 - class Provider( object ): """ Provider for Ext.Direct. This class handles building API information and routing requests to the appropriate functions, and serializing their @@ -444,15 +454,9 @@ class Provider( object ): 'defaults: { "anchor": "-20px" },' 'paramsAsHash: true,' """buttons: [{ - text: "Submit", - handler: function(){ - form = this.ownerCt.ownerCt; - form.getForm().submit({ - params: { - uid: 34 - } - }); - } + text: "Submit", + handler: this.submit, + scope: this }]""" '}', 'apiconf': ('{'