relatedRecords - Create

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

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.

Re: [pothompson] relatedRecords - Create

By Jason - March 30, 2010

Hi Paul,

I'm glad it pretty much worked. :)

Yeah, that solution will just bring you back to the list of projects. What it's doing is tricking the CMS into thinking you've clicked on the button to add a new record to the projects section. The "create" feature is on the requested functions list, however.

Good luck.
---------------------------------------------------
Jason Sauchuk - Project Manager
interactivetools.com

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