relatedRecords - Create

4 posts by 2 authors in: Forums > CMS Builder
Last Post: March 30, 2010   (RSS)

By pothompson - March 29, 2010

Is it possible from a list of relatedRecords to create a new relatedRecord, or are there any plans to introduce this?

I can see the 'modify' and 'erase' links, but it would be useful to add a 'create' link, even if it just started with a blank record (i.e. didn't have the 'related' field populated).

Thanks, Paul.

Re: [pothompson] relatedRecords - Create

By Jason - March 29, 2010

Hi,

Currently, there is no option to add a relatedRecord directly like that. However, it has been added to the requested function list.

There is a work around that you could try for now, though. Add a seperator to your section. Under field options, choose HTML and use the following code:


<tr>
<td colspan='2'>
<a href=admin.php?menu=*TABLENAME*&action=add&*RELATEDFIELD*=<?php echo$GLOBALS['RECORD']['*RELATEDFIELD']; ?>>Add Related Record</a>
</td>
</tr>


Change this code so that:
-*TABLENAME* = the name of the related table
-*RELATEDFIELD*= the name of the related field in that table

This will put a link below your related records. When you click on it, it will open an add window for you.

Let me know how this works for you.

Thanks for your input.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

Re: [Jason] relatedRecords - Create

By pothompson - March 30, 2010 - edited: March 30, 2010

Hi Jason,

Thanks for that, it was almost perfect! It worked exactly as I needed until when I clicked 'save', I was taken back to the list of records for the related record. I'll try and explain....

I have two tables, 'project types' and 'projects'. I want to hide 'projects' on the menu and just have 'project types' with related records showing all related projects. When somebody modifies, erases (and creates) a record, I'd like it to go back to the 'project types' record showing the related records again. This was something I suggested during the beta of v2.03 and was implemented so I guess I'll just need to hang on until the 'create' is implemented in the same way.

Your solution was perfect except that as I've said, when saving, it takes the user back to the 'projects' list which confuses them a bit.

Thanks for the help though, much appreciated.

Paul.