I've been hunting around the forum for the past hour but can't seem to find anything on this. Possibly because it's really obvious and I'm not getting it!

Basically I'm looking for some advice on the best approach to dealing with the following scenario. I'm a bit lost to know where to start.

The client wants a front end form (with no authentication or anything) for collecting people's details. It's a large form but mostly straight forward.

At one point they have a part of the form for 'employment history'. This takes the form of the following fields:

  • Employer
  • Year
  • Position

But they want the user to be able to ad multiple entries inside the one form (ie the user could ad 5 - 10 entries for employment history) via a button 'add another'.

Clearly I need a main section for the form with a linked one-to-many relationship with a subsection for employment history.

But I have no idea how to implement this on the front end? Can I use the SubSection manager some how? How would I handle input errors and validation?

The other issue is that all the entries need to be 'contained' in the one main entry (not just linked) so the client can export a CSV of the whole lot as one spreadsheet. So it really needs to be a subsection manager type arrangement I think...

I've read this tutorial by Brendo which answers some questions but I'm still a bit confused as to the best approach for creating multiple linked entries.

Any ideas or links to threads appreciated!

Having done a bit more research and playing around with Subsection Manager and the Import/Export CSV extension it seems that my criteria for having it all in one exportable CSV might exclude Subsection Manager from working as that only seems to out put the ID of the linked entry in the CSV...

So now I'm thinking I'll just have to limit the number of 'previous jobs' (probably not a bad idea anyway) to say 5 which will all be part of the same section as the form. I'll then show and hide the unused bits of the form with JS.

Probably a safer and less confusing way to do it. Would still love to know any other ideas though!

You might find this article by Brendo helpful, Symphony Events: A Detailed Look .

Having done a bit more research and playing around with Subsection Manager and the Import/Export CSV extension it seems that my criteria for having it all in one exportable CSV might exclude Subsection Manager from working as that only seems to out put the ID of the linked entry in the CSV...

You could also use the Content Type Mappings to create a frontend page that generates a downloadable CSV file. This way, you could use the SSM or similar.

what are your questions about brendo's tutorial? i recently finished a project identical to the one you are describing and would be happy to help.

Hey Fawx, The main thing I was confused about was how to add multiple new entries (ie 5 or 10) to the same subsection and link these back to main entry that is being created at the same time.

I also wasn't really sure of the best approach in the back end (ie subsection manager or select box link or something else?)...

Have you had experience collating all the info into a CSV? I think that Content Type Mappings extension looks like it might work for pulling certain reports but will have to have a good play around with it.

you can add multiple new entries by indicating a multidimensional array in your field names:

<input type="text" name="create-employment-history[name][0]" />

if you wrap these all in a fieldset, you can create an 'add another employer' button use jquery to clone the fieldset and replace the field names with a new number.

regarding linking to the primary application entry, brendo's tutorial outlines how to chain events together and give them priority. this way, the primary entry is created first and the subsequent child entries fill their relational fields (select box link, for example) with the appropriate output from $result, in this case, $result->getAttribute('id').

i realize this isn't a very detailed explanation and i would be happy to give code examples if it's not clear enough. i'd highly recommend memorizing brendo's tutorial, though as it contains all of the same information i would give you.

Ugh, I just typed out a super-detailed reply that pretty much outlined everything you need, but the board decided to end my session when I clicked 'Post Comment'. So frustrating.

Anyway, I'll summarize: you should check out the latest/dev version of the Dynamic Text Group extension. I created it pretty much for this.

Download the latest here.

Set up the Dynamic Text Group extension

Add the DTG field to your section. You'll want 3 text subfields: 1 for Employer, 1 for Dates, and 1 for Position. Add those 3 subfields using DTG's Field Editor and save your section. You'll notice that now when you create a new entry on the backend for your section, you're able to add a dynamic amount of jobs using DTG.

Create the event

Nothing special needs to be done here. Create your event as you normally would.

Set up the front-end

This is where you'll be doing most of your work. Basically, you need to emulate part DTG's functionality on the front-end. You'll need three things: (1) a holder on your page to contain the text input groups, (2) a link that triggers the addition of new groups of inputs to our holder, (3) a javascript function that generates a group of blank text inputs and appends them to our holder.

Study this example, which uses jQuery to do the heavy-lifting.

The addEmployment() function is what creates our empty text inputs. Note the name on those inputs— adding the empty bracket at the end of our inputs' names results in their data being posted as an array item. Therefore, we can add as many inputs as we need, and all the data will be sent to Symphony as a nice, clean array. DTG will take that array and insert each item into the database.

Also note that our names need to match those on the backend (or more specifically, the handles that have been generated on the back-end). In this example, I named my DTG instance "Employment", with the subfields I outlined above; my code reflects the handles of those names.

Hey Fawx and brockpetrie, Thanks so much for the replies - learning a lot by playing around with this. Still haven't quite got my head around everything but definitely well on my way! That extension is very interesting and I had no idea about arrays etc - so much to learn! Good though. Will keep tinkering and may come back if I get truly stuck. Thanks again.

has anyone ever had any luck making this work with multiple entries for one section? 'allow multiple' is enabled and the following is the (correct) output of a var_dump on $_POST['fields']:

[quantity] => Array
        [0] => 70
        [1] => 1
[sku] => Array
        [0] => CWC9-12
        [1] => CWC5-12
[name] => Array
        [0] => 88
        [1] => 88

however, the result set in the event xml is returned empty for this event (but not its parent) and no entries are created.

edit: got it, multiple entries' field names need to be in the form of fields[n][fieldname].

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details