unable to get form field values

Discussion in 'Cadence' started by piyush72, Apr 30, 2009.

  1. piyush72

    piyush72 Guest

    I have defined a form(say myForm), & bringing it up by loading in CIW
    Then I enter values for different fields

    But when I try :-

    foreach( f myForm->fieldList
    printf( "value of %L is %L\n", f f->value)
    )


    Values of all the fields are showing up as nil But if I type in
    fieldName->value in CIW , it shows my entered values
    I tried hiGetCurrentForm()->fieldList but that doesn't help either


    Pl. advise
     
    piyush72, Apr 30, 2009
    #1
  2. foreach(f myForm->fieldList
    printf( "value of %L is %L\n" f get(myForm f)->value)
    )

    In your case f is just the name of the field, and so to get the form field, you
    need to get from the form to the field itself (which is what the get(myForm f)
    is doing in my case).

    Regards,

    Andrew.
     
    Andrew Beckett, Apr 30, 2009
    #2
  3. piyush72

    Guest Guest

    Also note that fieldName->value and myForm->fieldName->value (or
    "get(myForm f)->value" which is the same thing) will give you different
    results in many cases.

    fieldName->value will dereference the field defstruct (assuming that you
    assigned the return value of hiCreate*Field to the symbol fieldName) which is
    the prototype for creating the field widget), where myForm->fieldName->value
    will dereference the actual value of the form's field.

    In some cases the independent field defstruct and the form's field will have
    the same value, but it is not reliable.

    -Pete Zakel
    ()

    "The more things change, the more they stay insane."
     
    Guest, Apr 30, 2009
    #3
  4. piyush72

    piyush72 Guest

    Thanks Andrew, Thanks Pete.



    Regards
    -Piyush
     
    piyush72, May 4, 2009
    #4
  5. Pete nospam Zakel wrote, on 04/30/09 20:51:
    And to clarify what Pete said a bit, fieldName->value would only work anyway if
    you'd got the field defstruct stored in a variable called fieldName. Even then
    it would not tell you the value of the field on the form, because you need to
    get to the instance of the destruct by accessing it from form->fieldName or
    get(form 'fieldName).

    Actually that may not have clarified it that much, reading through what I said.
    Hoh hum ;-)

    Regards,

    Andrew.
     
    Andrew Beckett, May 4, 2009
    #5
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.