Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: ViewModel is not updated when textfield data emptied for tf allowBlank is set to fals

    You found a bug! We've classified it as EXTJS-15302 . We encourage you to continue the discussion and to find an acceptable workaround while we work on a permanent fix.
  1. #1
    Sencha User
    Join Date
    Mar 2013
    Posts
    47

    Default ViewModel is not updated when textfield data emptied for tf allowBlank is set to fals

    Hello,

    I am not sure if I had the best title for this forum, but here it goes.

    First, fiddle is here (https://fiddle.sencha.com/#fiddle/hk7) so that will help what I am referring to.

    Working Scenario:
    I have text field for which value is bound to viewmodel data and allowBlank is set to true. In this case, if I modify the value to textfield and set it to empty, it will update viewModel data and set it to empty. This is correctly working as the textfield has two-way binding on the value.

    Error Scenario:
    I have another text field that also has value bound with a viewmodel data property. For this textfield, I have set allowBlank to false. Now, when I set the value to empty String, it does not update the ViewModel data, which I think is not working correctly. As the value of the textfield is two-way bound with viewmodel data, it should update data to property to empty string, but it does not.

    Did I just run into a bug with two-way binding not correctly working when allowBlank is set to false?

    Any help is appreciated.

    Thanks!

  2. #2
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120

    Default

    Thanks for the report! This is a known issue, so this thread has been updated with the bug number.

    Thanks!
    Joel

  3. #3
    Sencha User
    Join Date
    Mar 2013
    Posts
    47

    Default

    Thank you for your response Joel. If I get to implement the workaround, I will update this thread.

    Thanks!

  4. #4
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120

    Default

    Sure thing! Best of luck!

    Joel

  5. #5
    Sencha Premium User krullj's Avatar
    Join Date
    Sep 2011
    Posts
    123

    Default

    Did you ever find a workaround to this problem?

  6. #6
    Sencha User joel.watson's Avatar
    Join Date
    Nov 2014
    Posts
    3,120

    Default

    Quote Originally Posted by krullj View Post
    Did you ever find a workaround to this problem?
    This bug report is still open.

    Thanks
    Joel

  7. #7
    Sencha Premium User krullj's Avatar
    Join Date
    Sep 2011
    Posts
    123

    Default

    Oh, sorry. I should have directed my question at dhrpatel. He mentioned posting a workaround if he found one.

  8. #8
    Sencha User
    Join Date
    Mar 2013
    Posts
    47

    Default

    Set the viewModel data property manually in the change() event of the textfiedl to the newValue of the textfield.

  9. #9
    Sencha Premium Member
    Join Date
    May 2011
    Posts
    167

    Default

    Quote Originally Posted by dhrpatel View Post
    Set the viewModel data property manually in the change() event of the textfiedl to the newValue of the textfield.

    I made my own field, as this is in the field, not in a model setting, which is weird.

    Code:
    Ext.define('MyApp.AlwaysPublishTextField',{
    	extend:'Ext.form.field.Text',
    	 alias: 'widget.textfield-alwaysPublishValue',
    	//Override publish value so that it also will publish invalid values
    	publishValue: function () {
            var me = this;
    
    
            if (me.rendered ) {
                me.publishState('value', me.getValue());
            }
        }
    });

  10. #10
    Sencha Premium User krullj's Avatar
    Join Date
    Sep 2011
    Posts
    123

    Default

    pscanlon1, nicely done. I was looking at that method around the time you posted. The only difference is that I made the method an override.

    It's available at https://fiddle.sencha.com/#fiddle/pmi and is forked from dhrpatel's.

    I agree that it's weird. Especially since Models already have validators. I haven't checked other form fields, but I wonder if anything else prevents blank values from being sent to the ViewModel, and if so, why?

Page 1 of 2 12 LastLast

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •