Can I prepopulate a multiplier field?

prepopulate a multiplier field in ChronoForms.

Overview

The issue was caused by incorrect bracket placement in the PHP code used to set the default value.
Correct the array syntax in the code to properly assign the user's name to the specific field within the multiplier's first repeat.

Answered
fr fribse 19 May, 2016
I have a multiplier field and of course a multiplier-contents where I have a few fields defined.
FieldID: deltager[###][navn]


The multiplier has been set to show 1 repeat from the beginning, and I would like to prepopulate the 'navn' (name) field of that.
I've tried putting this code:
$form->data['deltager'['1']['navn']] = $user->get( 'name' ) ;

But it doesn't fill in in the first repeat?
Question is, does the repeat exist at all before I do a render html?
Gr GreyHead 19 May, 2016
Answer
1 Likes
Hi fribse,

Please try
$form->data['deltager']['1']['navn'] = $user->get( 'name' ) ;

Bob
fr fribse 20 May, 2016
Ahaa, brackets placed wrong :-) That made it work, thankyou very much!
This topic is locked and no more replies can be posted.