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.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
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
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
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.
I got it to work using the following syntax:
$form->record->{"hours_$i"}[$j]=...
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?
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).