Announcement

Collapse
No announcement yet.

Move some fields between the blocks at runtime

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

  • Move some fields between the blocks at runtime

    Hello everyone.
    maybe it's a stupid question, but I can not find a better solution.
    I need to move some fields between the blocks at runtime to avoid redundancy of fields in the db table.
    Ex.
    design:
    block_model_1
    -------
    date_model
    text1_model
    flagx_model

    block_model_2
    -------
    date_scad
    text2_demol

    block_model_3
    -------
    date_birth

    at run-time depending on the model (eg 1,2,3, etc) you have to input their respective fields that are common in the table
    eg. :
    if (model = 3)
    block_modello_1: no field
    block_modello_2: no field

    block_modello_3
    ---------------
    date_model
    text1_model
    date_scad
    date_birth

    Now I'm starting to deal with temporary fields in design and before the insert/update the table field assign to temporary field, but since many fields, redundancy is difficult to manage.

    Thanks to all
    hello
    Henry

  • #2
    A combination of macros should help you....

    Use macro sc_block_display() to display / hide a named block at runtime

    Use macro sc_field_display() to display / hide a field at runtime

    Comment


    • #3
      Speaking of blocks.....

      Why oh why can I not put a block inside another block?

      Dave
      Dave Prue
      Code Whisperer
      Lahar International Corp
      www.lahar.net

      Comment


      • #4
        thanks adz1111
        Ok what you say, but my question was: can I 'move' one field at runtime between a block and another?
        hello
        thanks
        Henry

        Comment


        • #5
          Henry

          OK - see what you mean now. If SC let you assign the same field to multiple areas then what I said would be nice n easy - but they don't, so it isn't! :-( Why they don't I do not know - same as per Dave's comment re nested blocks!

          So - the only way round it, off the top of my head, is pretty inelegant. You don't move the fields, but duplicate them (and I suspect you are doing something similar now given, your mention of temporary fields).

          You would need to duplicate the fields that need to appear in multiple blocks. Add these as fields in your Fields section. I would then create a PHP function that takes the "main" fields and creates / updates the duplicates with the values they need:

          Code:
          {dupe2} = {dupe1} = {main};
          And that function needs to be called whenever the data is refreshed, or form reloaded: onLoad etc. You can then use sc_block_display() / sc_field_display() macros as necessary.

          Comment

          Working...
          X