0

I have a edit user form. The form is loaded from a Json store with this code:

    var store = Ext.create('cp.store.form.Paciente',{});
    store.load({params:{idUsuario: idPaciente}});
    var form = Ext.create('cp.view.form.EditPaciente',{
        action: 'bin/paciente/modificar.php'
    });
    // note: write this lines in the controller
    form.on('afterrender',function(form,idPaciente){
       form.getForm().loadRecord(store.first());
       form.getForm().findField('idUsuario').setValue(idPaciente);
    });
    var win = Ext.create('cp.view.ui.DecoratorForm',{
        aTitle: 'Editar paciente',
        aForm: form
    });
    win.show();

The load code works fine. The submit code is:

var me = this;
    console.log('Submit...');
    console.log(this.url);
    // WHY NOT SUBMIT !!!!
    this.getForm().submit({
        console.log('submit !');
        success: function(form,action){
            if(action.result.success === true){
                Ext.create('cp.view.ui.AlertOk',{mensaje:action.result.msg}).showDialog();
                me.up('decoratorForm').close();
            }else{
                Ext.create('cp.view.ui.AlertErr',{mensaje:action.result.msg}).showDialog();
            }
        }
    });

So, the submit code starts running. FireBug shows the first and second "console.log", and the "this.url" value is correct. But, the third "console.log" not execute, and the form not send to the server. Firebug not says 404 error for "this.url" value. Any ideas ? Thanks !

Add the form definition:

Ext.define('cp.view.form.EditPaciente',{
    extend: 'Ext.form.Panel',
    alias: 'widget.editPaciente',


    bodyPadding: '5px 5px 5px 5px', 
    bodyStyle: 'border: none',
    fieldDefaults: {
        labelWidth: 65,
        labelAlign: 'top'
    },

    initComponent: function(){
        this.url = this.action,
        this.method = 'POST',
        this.items = [ .... ]
        this.callParent(arguments);
    }
});
ramiromd
  • 2,019
  • 8
  • 33
  • 62
  • Does the URL work when you access it outside of this script? A 404 is a 404... Also, the third console.log() is not executing, I suspect, because you placed it in a syntactically incorrect place. The options argument passed to submit() is an Object. – existdissolve May 29 '13 at 13:35
  • @existdisslove mmm the server side script runs outside of the application. Access with url: http://sigetumed.cp/bin/paciente/modificar.php and show in screen, "{'success':false, 'msg':'Faltan llenar campos obligatorios'}". Is good. Below post my form definition. – ramiromd May 29 '13 at 14:06
  • you should check your form's `submitUrl`, the problem is there. And also are you sure form has a property like `url`; I don't think so. Check [API](http://docs.sencha.com/extjs/4.2.1/#!/api/Ext.form.Panel) again. – talha06 May 30 '13 at 07:54
  • @talha06 thanks, i set url in submit action, but not work. – ramiromd May 30 '13 at 18:25

1 Answers1

0

You cant put log statements inside object literals.

  submit({                              <-- This is an object literal 
            console.log('submit !');    <-- This can not be in an object literal
            success: function(form,action){
                if(action.result.success === true){
                    Ext.create('cp.view.ui.AlertOk',{mensaje:action.result.msg}).showDialog();
                    me.up('decoratorForm').close();
                }else{
                    Ext.create('cp.view.ui.AlertErr',{mensaje:action.result.msg}).showDialog();
                }
            }
        });
dbrin
  • 15,525
  • 4
  • 56
  • 83