Announcement

Collapse
No announcement yet.

Hide fields using loop

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hide fields using loop

    Hi,

    I`v got a form with some fileds like this:

    field1
    field2
    field3
    ..
    field40

    I would like to hide them I can use sc_field_display macro but its not funny to write 40x this macro so i tried a loop like this

    Code:
    for ($i=1;$i <={dataset[0][0]}; $i++) {
        $name = "field" . $i;
        sc_field_display($name,"off");
    }
    but the source code looking like this:

    Code:
    for ($i=1;$i <=$this->dataset[0][0] ; $i++) {
      $nazwa = "exp" . $i;
      $this->nmgp_cmp_hidden["name"] = "off";
      $this->NM_ajax_info['fieldDisplay']['name'] = 'off';
    }
    macro sc_field_display doesn`t work with variables... so what now ?

    Now we have to wrote in our code:
    Code:
    for ($i=1;$i <={dataset[0][0]}; $i++) {
        $name = "field" . $i;
        $this->nmgp_cmp_hidden["".$name.""] = "off";
        $this->NM_ajax_info['fieldDisplay'][''.$name.''] = 'off';
    }
    And we got what we want
    I suggest to modify sc_field_display macro to work with variables


  • #2
    Re: Hide fields using loop

    Hello,

    there are other functions of SC which don't work with $variables.. but they work with &#91;] variables.
    You may try this way to use your variable. I myself did not try it.. it's only a tip.

    Best regards
    Uwe Pfeiffer

    Comment


    • #3
      Re: Hide fields using loop

      Place them in a block and hide the block(s).

      Regards,
      Scott.

      Comment

      Working...
      X