1. #91
    Sencha User
    Join Date
    May 2011
    Posts
    5
    Vote Rating
    0
    lduchesne is on a distinguished road

      0  

    Default


    Hello guys,

    I am new to ExtJS and I have issues to handle the server response after form submit.
    My website is based on Symfony 1.4.9 with dsExtDirectPlugin 1.0.5

    When I click Save Changes data is correctly submitted and saved in the database however when it comes to reply back to the client I get the error missing ) in parenthetical and the messageBox is not displayed.

    Below is the code I use :
    • in actions.class.php
    Code:
       public function executePersonalInfo(sfWebRequest $request)
        {
            $this->forward404Unless(
                $this->user = Doctrine_Core::getTable('sfGuardUser')->find(array('id' => $this->getUser()->getGuardUser()->getID()))    
            );
            
            $this->form = new sfGuardPersonalInfoForm($this->user);
    
            if ($request->isMethod('post'))
            {            
                $values['first_name'] = $this->getRequestParameter('first_name');
                $values['last_name'] = $this->getRequestParameter('last_name');
                $values['email_address'] = $this->getRequestParameter('email_address');
                [...]
                $values['id'] = $this->user->get('id');
                $values['_csrf_token'] = $this->getRequestParameter('_csrf_token');
    
                $this->form->bind($values);
    
                if ($this->form->isValid())
                {
                    $phpPersonalInfo = $this->form->save();
                    $this->result = array('success' => true);
                    return sfView::SUCCESS;
                }
            }
        }
    • in personalInfoSuccess.php
    Code:
    <?php use_javascript('extdirect_api.js') ?>
    <?php include_javascripts() ?>
    <?php use_helper('I18N') ?>
    
    <script type="text/javascript">
        Ext.onReady(function() {
            
            Ext.QuickTips.init();
    
            var formData = new Ext.FormPanel({
                url: 'PersonalInfo',
                renderTo: Ext.getBody(),
                title: 'Personal Information',
                width: 500,
                height: 400,
                padding: 10,
                id: 'personalInfo',
                items: [{
                        xtype: 'textfield',
                        fieldLabel: 'Firstname',
                        anchor: '100%',
                        name: 'first_name',
                        id: 'first_name',
                        allowBlank: false
                    },{
                        xtype: 'textfield',
                        fieldLabel: 'Lastname',
                        anchor: '100%',
                        name: 'last_name',
                        id: 'last_name',
                        allowBlank: false
                    },{
                        xtype: 'textfield',
                        fieldLabel: 'eMail',
                        anchor: '100%',
                        name: 'email_address',
                        id: 'email_address',
                        allowBlank: false,
                        vtype: 'email'
                    },
                    [...]
                    {
                        xtype: 'textfield',
                        fieldLabel: 'CSRF',
                        anchor: '100%',
                        name: '_csrf_token',
                        id: '_csrf_token',
                        hidden: true
                    }
                ],
                buttons: [{
                    text: 'Save Changes',
                    handler: function(){
                        formData.getForm().submit({
                            success: function(form, action){ Ext.Msg.alert('Success', 'It worked'); },
                            failure: function(form, action){
                                if (action.failureType == Ext.form.Action.CLIENT_INVALID) {
                                    Ext.Msg.alert('Form Error', 'Some fields are invalid');
                                } else if (action.failureType === Ext.form.Action.CONNECT_FAILURE) {
                                    Ext.Msg.alert('Failure', 'Server communication failure: '+ action.response.status+' '+action.response.statusText);
                                } else if (action.failureType === Ext.form.Action.SERVER_INVALID) {
                                    Ext.Msg.alert('Warning', action.result.errormsg);
                                }
                            }
                        })
                    }
                }]
            });
            Ext.getCmp('personalInfo').getForm().setValues({
                first_name:'<?php echo $user->getFirstName()?>',
                last_name:'<?php echo $user->getLastName()?>',
                email_address:'<?php echo $user->getEmailAddress()?>',
                _csrf_token:'<?php echo $form->getCSRFToken()?>'
            });
        });
    </script>
    Any help is very much appreciated
    Cheers

  2. #92
    Sencha User
    Join Date
    Feb 2012
    Location
    Paris
    Posts
    108
    Vote Rating
    1
    Tchinkatchuk is on a distinguished road

      0  

    Default


    Hi all,

    I don't know if it is the best place for this question but I can't find a way.
    How could I launch an event (notification I have in my app) when extdirect symfony plugin receive an exception ...

    Does anyone has a clue ?

    Thanks.

    Sylvain