title: How to set-up two objects in one package using MIGx - MODx Revolution
body: <p>I'm a novice in using MODx Revolution (2.2.8-pl), and I can't really find good enough resources to bring the project I'm currently working on, to a good finish.</p>
  
  <p>To make things short, I'm working on a photo/portfolio website and I need to create a couple of items in the database to store all the projects the photographer has worked on.</p>
  
  <p>I found this wonderful tool called MIGx, which is great and all, but I can't really figure out how to join two tables with it. (only for input)</p>
  
  <p>Basically what I'm trying to do is to add ONE item into the portfolio table, and for each Item, there's a description, date, quote ... and a list of images, each having its own description.</p>
  
  <p>So my guess is that I need two objects in the same package and a link between them.</p>
  
  <p>My XML schema looks something like this:</p>
  
  <pre><code>    &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;model package="portfolio" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" phpdoc-package="portfolio" phpdoc-subpackage="model" version="1.1"&gt;
      &lt;object class="portfolio_items" table="portfolio" extends="xPDOSimpleObject"&gt;
          &lt;field key="item_type" dbtype="varchar" precision="20" phptype="string" null="false" default=""/&gt;
          &lt;field key="item_date" dbtype="varchar" precision="10" phptype="string" null="false" default=""/&gt;
          &lt;field key="item_author" dbtype="varchar" precision="30" phptype="string" null="false" default=""/&gt;
          &lt;field key="item_title" dbtype="varchar" precision="250" phptype="string" null="false" default="" /&gt;
          &lt;field key="item_description" dbtype="varchar" precision="500" phptype="string" null="false" default="" /&gt;
          &lt;field key="item_text_color" dbtype="varchar" precision="10" phptype="string" null="false" default="grey" /&gt;
          &lt;field key="item_sections" dbtype="varchar" precision="100" phptype="string" null="false" default="" /&gt;
          &lt;field key="item_keywords" dbtype="varchar" precision="250" phptype="string" null="false" default="" /&gt;
          &lt;field key="main_img" dbtype="varchar" precision="100" phptype="string" null="false" default="" /&gt;
          &lt;field key="item_img" dbtype="varchar" precision="100" phptype="string" null="false" default="" /&gt;
          &lt;field key="published" dbtype="int" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" /&gt;
      &lt;/object&gt;
      &lt;object class=portfolio_item_section" table="item_content" extends="xPDOSimpleObject"&gt;
          &lt;field key="content_id" dbtype="int" precision="10" phptype="integer" null="false" default=""/&gt;
          &lt;field key="content_type" dbtype="varchar" precision="20" phptype="string" null="false" default=""/&gt;
          &lt;field key="content_title" dbtype="varchar" precision="100" phptype="string" null="false" default=""/&gt;
          &lt;field key="content_quote" dbtype="varchar" precision="500" phptype="string" null="false" default=""/&gt;
          &lt;field key="content_color" dbtype="varchar" precision="20" phptype="string" null="false" default="" /&gt;
          &lt;field key="content_main" dbtype="varchar" precision="2000" phptype="string" null="false" default="" /&gt;
              &lt;field key="content_image" dbtype="varchar" precision="100" phptype="string" null="false" default="grey" /&gt;
          &lt;field key="content_tags" dbtype="varchar" precision="10" phptype="string" null="false" default="" /&gt;
          &lt;composite alias="contentOwner" class="portfolio_table" local="content_id" foreign="id" cardinality="one" owner="local" /&gt;
      &lt;/object&gt;
  &lt;/model&gt;
  </code></pre>
  
  <p>So, what I'm trying to achieve is a link between the two objects and a way to add data through MIGx.</p>
  
  <p>I'm pretty sure that I have to create a template variable and call it in the MIGx formtabs,  which I pretty much did, but I don't know where to find good documentation for MIGx and how to make the damn thing work.</p>
  
  <p>I added an image of what the "Add item to the portfolio" window looks like. Theoretically, when the user clicks on "Add item", he can add as many images with descriptions and tags as he pleases.</p>
  
  <p><img src="https://i.stack.imgur.com/vDiYf.png" alt="Migx interface"></p>
  
  <p>Can you please point out how to config the Template variable so that it can add rows to the second object in the package?</p>
  
  <p>Right now it only displays a cute grid and an input field.</p>
  
  <p><img src="https://i.stack.imgur.com/CX4qT.png" alt="Template variable"></p>
  
  <p>Kind regards, 
  Alex</p>