[CLOSED] How to exclude a field from the Form?

  1. #1

    [CLOSED] How to exclude a field from the Form?

    Hi,

    I have a Checkbox residing in a CompositeField inside a FormPanel. I'd like to be able to exclude it from being a form field so that it doesn't get reset when I call

    FormPanel1.getForm().reset();
    I tried to set the Checkbox attribute IsFormField="false", but that didn't help. Please suggest the correct approach.
    Last edited by geoffrey.mcgill; Jul 30, 2012 at 8:53 PM. Reason: [CLOSED]
  2. #2
    Hi,

    I can't see any way without overriding the reset method.

    It looks:

    reset method
    reset : function(){
        this.items.each(function(f){
            f.reset();
        });
        return this;
    }
    So, I would suggest you to just implement an own function to reset the fields.
  3. #3
    Quote Originally Posted by Daniil View Post
    Hi,

    I can't see any way without overriding the reset method.

    It looks:

    reset method
    reset : function(){
        this.items.each(function(f){
            f.reset();
        });
        return this;
    }
    So, I would suggest you to just implement an own function to reset the fields.
    Thanks Daniil! I'm probably going to have to do something like this:
    var ctlsToExclude=[];
    ctlsToExclude[SomeField.id]=SomeField;
    FormPanel1.getForm().reset=function (ctlsToExclude) {
                                                                            this.items.each(function (f) {
                                                                            if (!ctlsToExclude[f.id])
                                                                                f.reset();
                                                                            });
                                                                            return this;
                                              };
    One more question on your suggestion: if the field I want to exclude resides on a CompositeField control, how can I exclude it from resetting so that the rest of CompositeField fields are intact? this.items.each(function (f) doesn't iterate through atomic fields, only CompositeFields.

    Or, if I could somehow take my field off the CompositeField but still display it on the same row with the that CompositeField as if it were part of it (last control), it would do the trick for me.
  4. #4
    Quote Originally Posted by vadym.f View Post
    Thanks Daniil! I'm probably going to have to do something like this:
    var ctlsToExclude=[];
    ctlsToExclude[SomeField.id]=SomeField;
    FormPanel1.getForm().reset=function (ctlsToExclude) {
                                                                            this.items.each(function (f) {
                                                                            if (!ctlsToExclude[f.id])
                                                                                f.reset();
                                                                            });
                                                                            return this;
                                              };
    Personally, I would prefer to define a new function to don't override the existing one.

    Quote Originally Posted by vadym.f View Post
    One more question on your suggestion: if the field I want to exclude resides on a CompositeField control, how can I exclude it from resetting so that the rest of CompositeField fields are intact? this.items.each(function (f) doesn't iterate through atomic fields, only CompositeFields.
    Probably, override the CompositeField reset as well :)


    Quote Originally Posted by vadym.f View Post
    Or, if I could somehow take my field off the CompositeField but still display it on the same row with the that CompositeField as if it were part of it (last control), it would do the trick for me.
    Well, if you don't need the CompositeField functionality (like combining errors), you could replace it with a Container with HBoxLayout.
  5. #5
    Quote Originally Posted by Daniil View Post
    Personally, I would prefer to define a new function to don't override the existing one.



    Probably, override the CompositeField reset as well :)




    Well, if you don't need the CompositeField functionality (like combining errors), you could replace it with a Container with HBoxLayout.
    Thanks for the suggestions Daniil! That helped me meet the requirement in question so you can mark this thread as closed.

Similar Threads

  1. Store - Exclude field names from data
    By glenh in forum 1.x Help
    Replies: 3
    Last Post: May 01, 2012, 7:05 AM
  2. Replies: 5
    Last Post: Jul 26, 2011, 12:17 PM
  3. Focus first field in form when TAB is pressed
    By chezinho in forum 1.x Help
    Replies: 2
    Last Post: Dec 08, 2010, 9:02 PM
  4. Form Field Renderer functions
    By fpw2377 in forum 1.x Help
    Replies: 5
    Last Post: Feb 25, 2010, 1:12 AM
  5. [CLOSED] [1.0] Form field name attribute
    By SandorD in forum 1.x Legacy Premium Help
    Replies: 2
    Last Post: Feb 22, 2010, 7:39 AM

Posting Permissions