154 Posts
WebOne
8 years ago
1
Topic

Hi,

I need to retrieve some values from GroupX fields via the Code Pack (PHP - BeforeStore) in a form.

The GroupX field in the form is 'groupxfield'. This form contains fields 'Field3' (grfield_3) and FIeld4 (grfield_4)

It has two items with proper storage:  Custom|Article|column_name[field] , Storage None

From the codepack beforestore when I do a print_r($fields['groupxfield']) I can see in the output, data entered into the GroupX fields

stdClass Object ( [id] => 5035 [title] => GroupxField [name] => groupxfield [folder] => 500 [type] => group_x [description] => [published] => 

.... 

...

bottombody [state] => [value] => 2 [text] => - GroupxField 0:

  • Field3 : 100
  • Field4 : 110

- GroupxField 1:

  • Field3 : 200
  • Field4 : 220

)

Here Field3 [0] had 100 entered and Field4 [0] had 110, Field3 [1] had 200 , Field4 [1] had 220

In the Code pack I tried using

$fields['group_x_fieldname']->value[0]['field1']->value 

ie.

$abc = $fields['groupxfield']->value[0]['grfield_3']->value;

$abc returns NULL / NO VALUE

I also tried printing out an array:

$array1 = array();
$c = intval($fields['groupxfield']->display);
for ($i = 0; $i < $c; ++$i) {
$array1[] = $fields['groupxfield']->value[$i]['grfield_3']->value;
}
print_r($array1);

which returns :

Array ( [0] => [1] => [2] => )

I also tried:

$array1 = array();
$c = intval($fields['groupxfield']->display);
for ($i = 0; $i < $c; ++$i) {
$array1[] = $fields['groupxfield']->form[$i]['grfield_3']->value;
}
print_r($array1);

which still returns nothing :

Array ( [0] => [1] => [2] => )

So now what code do I need to retrieve GroupX values from the array   $fields['groupxfield']  in the Code Pack?

Thank you

Need some help?

1 replies have been added to this thread, and the topic is marked as solved.
You should subscribe to a club in order to read all posts.