Menu

variable object variable names

Help
2004-10-21
2013-04-01
  • David J Caroline

    on setting the field object names in tr.php

    for ($i=0; $i<7; $i++)
      $block -> add_property(new NumericProperty("hours_$i", $days[$i], "", FALSE, 2, 1));

    one cannot it seems have:

    $form->record->hours_$i[$j]

    do the same when retrieving the data for saving

    any ideas any body

     
    • David J Caroline

      ignore
      answer is

      for ($i=0; $i<$fieldcount; $i++) //i =cols

      $form->record->{$fieldnames[$i]}[$j] =$old["$fieldnames[$i]"];

      its the use of curly braces for variable varibles

       
      • Alexei Peterkin

        Alexei Peterkin - 2004-10-22

        I actually didn't find this to work.

        This situation is pretty rare, and the loop was just created to make the code shorted, but I would have accessed the values using ->hours_0, ->hours_1, etc.

        If you really want to cycle through such values, then two techniques may work:

        1)use $form->record->_properties["hours_$i"]->
        to call get_value and set_value methods.

        2) Use the following construct
        $name = "hours_$i";
        $array = & $form->record->$name;
        and then access the values using $array[].

        Both look clumsy, but the situation is very rare.

         
      • Alexei Peterkin

        Alexei Peterkin - 2004-10-22

        I got it to work using the following syntax:

                 $form->record->{"hours_$i"}[$j]=...

         
    • argy

      argy - 2005-08-16

      As it seems to be the right place, I want to change the Display Value of a submit button.

      But first I should check for is_record_existing so it's not possible at declaration time. So what exactly is the appropriate method or variable that will change the Submit buttons display value?

       
      • Alexei Peterkin

        Alexei Peterkin - 2005-08-16

        If I understand you correctly, you want the label on the button to show different text, depending on whether the record is an existing one or a new one.

        The way buttons are implemented is such that you cannot do it - the form processor looks for matching button name and button label pairs among submitted values. You can change the label before displaying the form, but the part that restores the form from the submitted values won't know about the change, unfortunately.

        What I do instead, is define two buttons, and then hide the one that I don't need in the pre-display trigger (assuming that you are using standard layouts).

         

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.