1. #1
    Sencha User
    Join Date
    Sep 2012
    Posts
    144
    Answers
    19
    Vote Rating
    0
    coletek is on a distinguished road

      0  

    Default Answered: How do I add a variable to a form panel

    Answered: How do I add a variable to a form panel


    Say I have a form with one field such as below, then how do I add a addition value to the form values, so its passed in the submit() call (as commented below):

    Code:
    Ext.define("test.view.AddCommentForm", {
        extend: 'Ext.form.Panel',
        xtype: 'addcommentform',
    
    
        requires: [
            'Ext.form.TextArea',
            'Ext.field.Hidden'
        ],
    
    
        config: {
            title: 'Add Comment',
            url: 'backend/add_comment.php',
            scrollable: false,
    
    
            items: [
                {
                    xtype: 'fieldset',
                    title: 'Add Comment',
    
    
                    items: [
                        {
                            xtype: 'textareafield',
                            name: 'comment',
                            label: 'Comment',                                     
                            labelWidth: 150,
                            placeHolder: '',
                            required: true,
                            margin: 20,
                        }
                    ]
                },
                {
                    id: 'button-send',
                    xtype: 'button',
                    text: 'Send',
                    ui: 'confirm',
                    handler: function() {
    
    
                        var to_user_id = 50; // how do I add this to the form values, so they get passed in the submit call below, without having to add it to the item list above?
    
    
                        var values = this.up('addcommentform').getValues();
    
    
                        if (!values.comment)
                        {
                         	Ext.Msg.alert('Add Comment', 'Please enter your comment');
                        }
                        else if (!values.to_user_id) // clearly this will not work until the above variable to_user_id is added to the values
                        {
                         	Ext.Msg.alert('Add Comment', 'No user selected');
                        }
                        else
                        {
                         	this.up('addcommentform').submit({
                                success: function(form, result) {
    				Ext.Msg.alert('Add Comment', 'Added comment successfully');
    				form.reset();
                                },
                                failure: function(form, result) {
    				Ext.Msg.alert('Add Comment', 'An error occurred, please try again later');
                                }
    			});
                        }
    
    
    		}
    
    
                }
    	]
    
    
        }
    
    
    });
    What comes around goes around

  2. Solved with following after "var to_user_id = 50;"

    Code:
    this.up('addcommentform').add({
                            xtype: 'hiddenfield',
                            name: 'user_id',
                            value: to_user_id
                        });

  3. #2
    Sencha User
    Join Date
    Sep 2012
    Posts
    144
    Answers
    19
    Vote Rating
    0
    coletek is on a distinguished road

      0  

    Default


    Solved with following after "var to_user_id = 50;"

    Code:
    this.up('addcommentform').add({
                            xtype: 'hiddenfield',
                            name: 'user_id',
                            value: to_user_id
                        });
    What comes around goes around

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar