10 years ago
11
Topic
Is it possible to add a sub-form to a form?

For example, if I have a front-end form where a user can create a new Author, can I embed a Books subform that will allow the user to create books that this author has written?  Ideally the books sub-form would pickup the name of the author from the parent Author form.

Thanks for any ideas!
Get a Book for SEBLOD
4229 Posts
Kadministrator
10 years ago
0
Level 1
Hi,

group x is actually pretty close to subform, you just need to make sure you setup storage right so that books will be stored in separate database

http://www.seblod.com/resources/tutorials/how-to-manage-fields-storage
10 years ago
1
Level 1
You have one field where the user enters an author.

Then you can have a Field X (if only book title) or group X field (if title, year etc.) for the books. Be careful about the storage, like Klas said.

To associate authors and books, you need the author id. If the author does not exist yet, you can get the id in the database with the SD Field Concat Plugin. This can get the id in the database of an article before that article gets saved.

This id you can store in the books table along with the title and maybe other info.

Later you can relate the author to the books by this id.  James Morrell has an excellent video about content relationships that uses authors and books as example.

10 years ago
0
Level 2
Hmmm... but won't that only store a single article with combined information about the author and the book?  Or is there some mechanism in the above that forces the storage of two articles (maybe the act of forcing the book to be stored in a separate table than the author?)  I'll need to be able to view the book article separately from the author article.

Thanks to you both for your replies!
10 years ago
1
Level 1
Thats right, it will only store the author as Joomla article and the books would have to be stored in a separate table.

I can't think of a way how to store author and books simultaneously as separate articles from within one form.

Would be great if someone could come up with an idea how to achieve that.

As a workaround you could have separate forms for authors and books. After submitting an author you could redirect the user to the book submit form for that author.
10 years ago
0
Level 2
Yeah, the redirect is a good idea!  Or it seems like maybe this Button Free plugin allows you to create a subform: http://www.seblod.com/products/921 but I'm not sure.  Octopoos?
Thanks again gebeer!
10 years ago
0
Level 1
The Button Free plugin looks very promising.
Form – Displays a form. Useful for adding content to another (or related) content type, with redirection back to the original form.
If I understand this right, you can include a form into a form and then redirect after submit of the subform.

Seems to be exactly what you are looking for.

If you try it and it works, please report back here. Thank you.
4229 Posts
Kadministrator
10 years ago
0
Level 1
Seems you have 3 options, most likely nb. 3 will fit you the most

  1. If it is ok to store data to the same record (but as far as I understood this question it is not) you can use group x
  2. Free button will redirect user to another form and when they are done they are redirected back to the original form.
  3. If you need the form to be displayed inline you can use module field and then display seblod from module in this field, this will create 2 articles (each form has separate data storage)


4229 Posts
Kadministrator
10 years ago
1
Level 1
Turn out there is even a better option -> nb. 4 :) http://www.seblod.com/products/8538
10 years ago
0
Level 2
Hi guys and thank you very much for your suggestions!

Option #4 would be ideal, but the plugin only seems to show a form in the Content view, whereas I need to have it appear in the Admin and Site forms (basically embedding a form as a sub-form).  I'm trying to get Option #3 to work as the next alternative, but I can't get it to appear in the Admin or Site forms -- does it maybe suffer the same limitation as the plugin for Option #4?

Thanks!
4229 Posts
Kadministrator
10 years ago
1
Level 1
Hi,

nb. 4 actually consists of 2 plugins, with form plugin you should be able to show subsforms in admin/site form.
10 years ago
0
Level 2
Ah, you're right!  I purchased this plugin.  Any idea how to get the article ID from the parent article?  I was checking out SD Live CCK Field plugin, but Simon states that his plugin only works when there's one article in play.
Thanks!
Get a VIP membership