1. #1
    Sencha User
    Join Date
    Jun 2008
    Posts
    77
    Vote Rating
    0
    PSB is on a distinguished road

      0  

    Default How set default value in form?

    How set default value in form?


    I need to set default value in form field in Architect 2:


    In datetime field - new Date();
    In textfield field - Ext.getStore("Application_store").getCookie("user_login");


    ...But Architect changed this values in only text values. How do i this do?

    Thanks!

  2. #2
    Sencha User marcusvar's Avatar
    Join Date
    Feb 2010
    Location
    Ji-Paraná - Rondônia - Brasil
    Posts
    14
    Vote Rating
    0
    marcusvar is on a distinguished road

      0  

    Default How set default value in form?

    How set default value in form?


    Does anyone have an answer to the question of PSB? I have the same doubt.

  3. #3
    Sencha User
    Join Date
    Jun 2008
    Posts
    77
    Vote Rating
    0
    PSB is on a distinguished road

      0  

    Default


    BUMP!!!

    need set dynamic width:

    width: if(a==1)? 100 : 200


    Architect convert this in text:
    width: 'if(a==1)? 100 : 200'



  4. #4
    Sencha User net02's Avatar
    Join Date
    Feb 2012
    Location
    Pavia, Italy
    Posts
    6
    Vote Rating
    3
    net02 is on a distinguished road

      0  

    Default


    I'd suggest using an event handler to set up form 'dynamic' default values and/or configs.
    I usually use the activate event of the form panel which is handy because it's fired every time the form is actually shown inside its container (the main Viewport, a navigation view, a tab panel or whatever). This way you can use the same form panel both for inserting and editing purposes, and reload the default value whenever there's no record - thus no value - set to the form.
    Here's a quick example:

    Code:
    var field = this.getFields('field_name_config');
    if (!field.getValue()) {
      field.setValue(new Date());
    }
    Otherwise you can also rely on the initialize event of the field itself, but it will trigger only once upon the form panel's creation. In that case, you'll need to stick just this one-liner into the code editor:
    Code:
    this.setValue(new Date());

Thread Participants: 2