Looks like we cannot reproduce this. Please provide another test case to reproduce this issue.
  1. #1
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default Form panel textfield default value bug

    Form panel textfield default value bug


    Sencha Touch version tested:
    • Touch 2.1.1
    Browser versions tested against:
    • Chrome 25
    • Safari 5.1.8
    Description:
    • For a form panel, use of the name property does not allow loading of default value for xtype: "textfield"
    Code block of interest:

    Code:
    {    
    
        xtype: 'textfield',
        name: 'latitude',
        label: 'Latitude',
        itemId: 'latitude',
        value: sessionStorage.latitude             
    
    },
    When I comment out the name property the default value gets loaded into the textfield as expected. However, I want this to be automatically included on form submit(), so this is a problem.

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,821
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    That should be no different if you used 'foo' instead of sessionStorage.latitude and this works for me:

    Code:
    Ext.Viewport.add({
        items : [
            {
                xtype  : 'textfield',
                name   : 'latitude',
                label  : 'Latitude',
                itemId : 'latitude',
                value  : 'foo'
            }
        ]
    });
    Is sessionStorage.latitude available when this code is evaluated by the browser (not just when you create an instance if this isn't in a method).
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  3. #3
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default


    Hi Mitchell,
    Yes, I know 'foo' should do the same as sessionStorage.latitude (which, yes, does exist when this gets called). In fact, I have tried setting this to a constant string with the same result: nothing displayed in the textfield.

    My problem is not with a viewport, but a form panel. Here is my full form panel:

    Code:
    Ext.define('EvaluateIt.view.GeolocationEdit', {
        extend: 'Ext.form.Panel',
        alias : 'widget.geolocationEdit',
        requires: [
            'Ext.form.Panel',
            'Ext.form.FieldSet',
            'Ext.field.Number',
            'Ext.field.DatePicker',
            'Ext.field.Select',
            'Ext.field.Hidden'
        ],
        config: {
         
        // We give it a left and top property to make it floating by default
            left: 0,
            top: 0,
    
    
            // Make it modal so you can click the mask to hide the overlay
            modal: true,
            hideOnMaskTap: true,
    
    
            // Set the width and height of the panel
            width: 400,
            height: 330,
            scrollable: true,
             layout: {
                type: 'vbox'
            },
            defaults: {
                margin: '0 0 5 0',
                labelWidth: '40%',
                labelWrap: true
            },
            items: [
                {
                    xtype: 'datepickerfield',
                    destroyPickerOnHide: true,
                    name : 'datOfEvaluatione',
                    label: 'Date of evaluation',
                    value: new Date(),
                    picker: {
                        yearFrom: 1990
                    }
                },
                {    
                       xtype: 'textfield',
                       name: 'address',
                       label: 'Address',
                       itemId: 'address' 
                },
                {    
                       xtype: 'textfield',
                       //name: 'latitude',
                       label: 'Latitude',
                       itemId: 'latitude',
                    //id: 'latitude',
                     value: 'foo'            
                },
                {    
                       xtype: 'textfield',
                       //name: 'longitude',
                       label: 'Longitude',
                       itemId: 'longitude',
                     value: 'bar'
                },
                {    
                       xtype: 'textfield',
                       //name: 'accuracy',
                       label: 'Accuracy',
                       itemId: 'accuracy',
                     value: 'foo bar'
                },
                {
                    xtype: 'button',
                    itemId: 'save',
                    text: 'Save'
                }
                
            ]
        }
    });
    Thanks!

  4. #4
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,821
    Vote Rating
    836
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    It doesn't matter where the textfield is, displaying the value will be the same. With our code, without modification, the following screenshot is what I see:

    Screen Shot 2013-04-08 at 10.19.25 AM.png

    This is how I created it:

    Code:
    var form = new EvaluateIt.view.GeolocationEdit();
    
    Ext.Viewport.add(form);
    form.show();
    Mitchell Simoens @SenchaMitch
    Sencha Inc, Senior Forum Manager
    ________________
    Check out my GitHub, lots of nice things for Ext JS 4 and Sencha Touch 2
    https://github.com/mitchellsimoens

    Think my support is good? Get more personalized support via a support subscription. https://www.sencha.com/store/

    Need more help with your app? Hire Sencha Services services@sencha.com

    Want to learn Sencha Touch 2? Check out Sencha Touch in Action that is in print!

    When posting code, please use BBCode's CODE tags.

  5. #5
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default


    Hi Mitchell,
    It's not that I don't believe you, since this is the behavior I expected for my form, it is just that it is not working! The only way I can get the default value to show up in the textfield is to comment out the name property.

    Any recommendations for next steps?

    Thanks!

    Greg--

  6. #6
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default


    I will try the viewport later today and let you know the outcome, but if indeed it uses the same code base to render the form, then I am expecting that it will not work for me.

    Greg--

  7. #7
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default


    Hi Mitchell,
    I tested loading a default value in a textfield in the Kitchensink app form... and it worked! Not sure what is different with my app, especially since I borrowed a lot of components from the Kitchensink. I am going to try and isolate it later, so I will let you know when I find what is causing this odd behavior.

  8. #8
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default The problem is...

    The problem is...


    Hi Mitchell,
    I isolated the problem. The list of addresses to which I wish to add geolocation coordinates (and to display them on a map) is rendered in a form panel. When I click on the address of interest an onTap is fired to do the following:

    Code:
    onSelectGeolocation: function(view, index, target, record, event) {
            console.log('Selected a Geolocation from the list');
            var geolocationForm = Ext.Viewport.down('geolocationEdit');
    
    
            if(!geolocationForm){
                geolocationForm = Ext.widget('geolocationEdit');
            }     
            geolocationForm.setRecord(record);
            geolocationForm.showBy(target);
    }
    The line that uses the setRecord method to write any existing records in my store to the form elements is what is preventing the default values from getting written to the desired form elements. When I comment this out, all is good. Problem is that I need to grab those records that exist in the store, e.g., address, to display in my form. How can I do this AND write default values to my textfield elements in my form?


    Thanks for your help on this!

  9. #9
    Sencha User
    Join Date
    Feb 2013
    Posts
    48
    Vote Rating
    0
    horcle_buzz is on a distinguished road

      0  

    Default


    I figured out how to get what I want using Ext.getCmp.