1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    13
    Vote Rating
    0
    geverend is on a distinguished road

      0  

    Default ComboBox won't post original name when HiddenName is set

    I'm trying to figure out if it's possible to post both the text and the value from a combobox.

    When I set HiddenName to post back the the value, the original name field is no longer set.

    I'd like to post back both the name and value so I don't need to do extra database lookups after posting back to the server.


    Thanks

  2. #2
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    2
    devnull is an unknown quantity at this point

      0  

    Default

    it is possible, but youll need some custom code in the submit handler to do it.

  3. #3
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,570
    Vote Rating
    53
    Animal will become famous soon enough Animal will become famous soon enough

      0  

    Default

    Use name and hiddenName, then both will be submitted.

  4. #4
    Ext User
    Join Date
    Jul 2007
    Posts
    3,128
    Vote Rating
    2
    devnull is an unknown quantity at this point

      0  

    Default

    Are you sure? I thought I had tried that and i just got the hiddenName value.

  5. #5
    Ext User
    Join Date
    Apr 2008
    Posts
    13
    Vote Rating
    0
    geverend is on a distinguished road

      0  

    Default

    Just tried the same thing, and it didn't work.

    The control I'm applying the element to actually already has the name property set, but I'm re-setting it in the combobox config.

    When I step through the code using firebug, I can actually see the name parameter dissapearing.

  6. #6
    Sencha - Ext JS Dev Team Animal's Avatar
    Join Date
    Mar 2007
    Location
    Notts/Redwood City
    Posts
    30,570
    Vote Rating
    53
    Animal will become famous soon enough Animal will become famous soon enough

      0  

    Default

    Ah. applyTo changes things. It converts the select into a ComboBox. If you just create a ComboBox with name and hiddenName it should work for you.

  7. #7
    Ext User
    Join Date
    Apr 2008
    Posts
    13
    Vote Rating
    0
    geverend is on a distinguished road

      0  

    Default

    Got it. Thanks!

  8. #8
    Ext User phpeter's Avatar
    Join Date
    Apr 2007
    Posts
    7
    Vote Rating
    0
    phpeter is on a distinguished road

      0  

    Default Got the same problem - proposed solution doesn't work

    "If you just create a ComboBox with name and hiddenName it should work for you."

    With extjs 2.2 and this combobox:

    {
    xtype:"combo",
    store: new Ext.data.SimpleStore({
    url: Ext.PHP_BASIS_URL+'supporttickets/getMitarbeiters/',
    fields:['id','name']
    }),
    typeAhead:true,
    typeAheadDelay:10,
    selectOnFocus:false,
    fieldLabel: 'Besitzer',
    displayField:'name',
    valueField:"id",
    name: 'mitarbeitername',
    hiddenName:'mitarbeiter',
    minChars:1,
    querydelay:10
    }

    ...only the value of the valueField is submitted as "mitarbeiter", the value of the displayfield is not submitted. Is there a way to submit both fields ? Thx in advance.

  9. #9
    Ext User
    Join Date
    Apr 2008
    Posts
    13
    Vote Rating
    0
    geverend is on a distinguished road

      0  

    Default solution when using applyTo

    Since I'm using applyTo to add it to an existing HTML form, I needed another workaround.

    I used getElementByID to get the original control, and saved it in a variable called originalval.

    Then after loading the combobox, I set combobox.name = originalname.

    I'm not sure if this solution applies to you, phpeter, since you're not using applyTo.

  10. #10
    Sencha - Community Support Team Condor's Avatar
    Join Date
    Mar 2007
    Location
    The Netherlands
    Posts
    24,246
    Vote Rating
    112
    Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of Condor has much to be proud of

      0  

    Default

    Quote Originally Posted by Animal View Post
    Ah. applyTo changes things. It converts the select into a ComboBox. If you just create a ComboBox with name and hiddenName it should work for you.
    Nope. ComboBox.onRender removes the name attribute from el if hiddenName is set.

    And you can't simply override onRender to remove the line, because Ext.form.Field.getName depends on it.