Forums

Multiple entry form system

peterswa62 21 Feb, 2013
I am basing a multiple entry form system based on your example you posted on FAQ recently:-

http://www.chronoengine.com/faqs/2700-how-can-i-have-a-button-to-add-more-form-inputs.html

I put the code in a custom code block and I understand it mostly but am not sure about how you process the data so it goes into form->data like below and you can see the output in the debugger, as you are not using a DB Record Loader.

[recipient] => Array (
  [1] => Array (
    [name] => Simon
    [address] => 12 High Steet
  )
  [2] => Array (
    [name] => Steven
    [address] => 72 Main Street
  )
  [3] => Array (
    [name] => Sue
    [address] => 4 Back Street
  )
  [4] => Array (
    [name] => Sally
    [address] => 99 ave de l'Opera
  )
  [5] => Array (
    [name] => Sherlock
    [address] => 1278 6th Steet
  )
)
GreyHead 21 Feb, 2013
Hi peterswa62,

It's not processed at all - its just the way the names are set up, for example
name='recipient[{$i}][address]'
will give you
$form->data['recipient'][1]['address']
$form->data['recipient'][2]['address']
$form->data['recipient'][3]['address']
. . .
in the results.

So the data you see in the debugger is just from those input names.

Bob
peterswa62 22 Feb, 2013
Thanks I understand now. When it comes to saving the data would the right approach be to put a Custom Code block on the OnSubmit event with code to save the data to the database? Also loading data into the form, would you have to write custom code to load the data in the Custom Element?
GreyHead 25 Feb, 2013
Hi peterswa62 ,

Probably, but it does depend on how you are going to save the repeated data, which in turn depends on what you plan to do with it.

Bob
This topic is locked and no more replies can be posted.