One entry populating two fields [Solved]

PaulT

Member
Is it possible to enter data into one field which then saves that same data into another hidden field in a different group on the same form?
 
You'd have to write a little custom JS in an element JS event. So on the first field, add a 'change' event which does ...

Fabrik.blocks['form_X'].formElements.get('yourtable___hidden').update(this.getValue());

Replace 'yourtable___hidden' with the full element name of the hidden element.

If the 'change' event doesn't work, use a 'blur' event.

-- hugh
 
I added following code to the Javascript custom code box and tried with a "change" event and "blur" event but neither worked. May be because I forgot to mention the hidden field is in a repeating group?
Fabrik.blocks['form_7'].formElements.get('geh_clients_77_repeat___client_name').update(this.getValue());
 
Yes I want every repeat to contain that same data. Basically they fill in the clients name in the client group (non repeating) this group contains the clients main address also. In the repeat groups (Sites) they are adding site locations of that client. One client can have many sites (locations), Each time they add a new location I want the clients name to be added to that group but they don't have to see it (that is why it is hidden). The main reason it is there at all is for cascadingdropdowns that occur later in other forms.
 
That's ind of problematic, as you would also need to account for them adding a new group, as well changing all existing groups when they change the name.

It might be easier to do it in a PHP submission plugin, running 'onBeforeProcess'.

Code:
foreach ($formModel->formData['eh_clients_77_repeat___client_name'] as $key => $value) {
   $formModel->formData['eh_clients_77_repeat___client_name'] [$key] = $formModel->formData['maintable___mainelement'];
   $formModel->formData['eh_clients_77_repeat___client_name_raw'] [$key] = $formModel->formData['maintable___mainelement_raw'];
}

-- hugh
 
We are in need of some funding.
More details.

Thank you.

Members online

No members online now.
Back
Top