<![CDATA[ Adding authors for articles - MODX Community Forums]]> https://forums.modx.com/thread/?thread=103008 <![CDATA[Adding authors for articles]]> https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554599
XML:
<?xml version="1.0" encoding="UTF-8"?>

<model package="authors" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
    <object class="myAuthor" table="my_authors" extends="xPDOSimpleObject">
        <field key="surname" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <field key="initials" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <field key="email" dbtype="text" phptype="string" null="false" default="" />
		<field key="orcid" dbtype="text" phptype="string" null="false" default="" />

        <field key="university" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
        <field key="mod_user" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" default="0" />
		
		<field key="resource_id" dbtype="int" precision="11" phptype="integer" null="false" default="0" />
		<field key="resource_ids" dbtype="text" phptype="string" null="false" default="" />

        <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />

        <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/> 

        <aggregate alias="University" class="myUniversity" local="university" foreign="id" cardinality="one" owner="foreign" />
        <aggregate alias="User" class="modUser" local="mod_user" foreign="id" cardinality="one" owner="foreign" />
		<aggregate alias="Resource" class="modResource" local="resource_id" foreign="id" cardinality="one" owner="foreign" />
    </object>

    <object class="myUniversity" table="my_universities" extends="xPDOSimpleObject">
        <field key="name" dbtype="varchar" precision="255" phptype="string" null="false" default=""/>
        <field key="abb" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
		<field key="address" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>
		<field key="country" dbtype="varchar" precision="100" phptype="string" null="false" default=""/>

        <field key="deleted" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />
        <field key="published" dbtype="tinyint" precision="1" attributes="unsigned" phptype="integer" null="false" default="0" />

        <field key="createdon" dbtype="datetime" phptype="datetime" null="true"/> 

        <composite alias="Authors" class="myAuthor" local="id" foreign="university" cardinality="many" owner="local" />
    </object>
</model>


Export JSON:

{
  "formtabs":[
    {
      "MIGX_id":7,
      "caption":"Info",
      "print_before_tabs":"0",
      "fields":[
        {
          "MIGX_id":23,
          "field":"surname",
          "caption":"\u0424\u0430\u043c\u0438\u043b\u0438\u044f",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":1
        },
		{
          "MIGX_id":24,
          "field":"initials",
          "caption":"\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u044b",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":2
        },
        {
          "MIGX_id":25,
          "field":"email",
          "caption":"\u041f\u043e\u0447\u0442\u0430",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"email",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":3
        },
        {
          "MIGX_id":27,
          "field":"university",
          "caption":"\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442",
          "description":"",
          "description_is_code":"0",
          "inputTV":"",
          "inputTVtype":"listbox",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"@SELECT '' AS `name` ,'' AS `id` FROM `[[+PREFIX]]my_universities` UNION SELECT `name`,`id` FROM `[[+PREFIX]]my_universities` WHERE `deleted` = 0",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":4
        },
        {
          "MIGX_id":28,
          "field":"mod_user",
          "caption":"\u041f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c",
          "description":"",
          "description_is_code":"0",
          "inputTV":"select-user",
          "inputTVtype":"",
          "validation":"",
          "configs":"",
          "restrictive_condition":"",
          "display":"",
          "sourceFrom":"config",
          "sources":"",
          "inputOptionValues":"",
          "default":"",
          "useDefaultIfEmpty":"0",
          "pos":5
        }
      ],
      "pos":1
    }
  ],
  "contextmenus":"update||recall_remove_delete",
  "actionbuttons":"addItem||toggletrash",
  "columnbuttons":"",
  "filters":[
        {
            "MIGX_id":1,
            "name":"search",
            "label":"search",
            "emptytext":"Seatch bu surname...",
            "type":"textbox",
            "getlistwhere":{
                "surname:LIKE":"%[[+search]]%",
                "OR:university:LIKE":"%[[+search]]%"
            },
            "getcomboprocessor":"",
            "combotextfield":"",
            "comboidfield":"",
            "comboparent":"",
            "default":""
        }
    ],
  "extended":{
    "migx_add":"",
    "disable_add_item":"",
    "add_items_directly":"",
    "formcaption":"",
    "update_win_title":"",
    "win_id":"authors",
    "maxRecords":"",
    "addNewItemAt":"bottom",
    "multiple_formtabs":"",
    "multiple_formtabs_label":"",
    "multiple_formtabs_field":"",
    "multiple_formtabs_optionstext":"",
    "multiple_formtabs_optionsvalue":"",
    "actionbuttonsperrow":4,
    "winbuttonslist":"",
    "extrahandlers":"",
    "filtersperrow":4,
    "packageName":"authors",
    "classname":"myAuthor",
    "task":"",
    "getlistsort":"",
    "getlistsortdir":"",
    "sortconfig":"",
    "gridpagesize":"",
    "use_custom_prefix":"0",
    "prefix":"",
    "grid":"",
    "gridload_mode":1,
    "check_resid":1,
    "check_resid_TV":"",
    "join_alias":"",
    "has_jointable":"yes",
    "getlistwhere":"",
    "joins":[
      {
        "alias":"University",
        "selectfields":"name"
      }
    ],
    "hooksnippets":"",
    "cmpmaincaption":"\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0411\u0414 \u005c\u0022\u0410\u0432\u0442\u043e\u0440\u044b\u002c \u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442\u044b\u005c",
    "cmptabcaption":"\u0410\u0432\u0442\u043e\u0440\u044b",
    "cmptabdescription":"\u041c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 \u0430\u0432\u0442\u043e\u0440\u043e\u0432",
    "cmptabcontroller":"",
    "winbuttons":"",
    "onsubmitsuccess":"",
    "submitparams":""
  },
  "columns":[
    {
      "MIGX_id":2,
      "header":"id",
      "dataIndex":"id",
      "width":"",
      "sortable":"false",
      "show_in_grid":"0",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":1,
      "header":"\u0424\u0430\u043c\u0438\u043b\u0438\u044f",
      "dataIndex":"surname",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
	{  
	  "MIGX_id":6,
      "header":"\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u044b",
      "dataIndex":"initials",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":5,
      "header":"\u0423\u043d\u0438\u0432\u0435\u0440\u0441\u0438\u0442\u0435\u0442",
      "dataIndex":"University_name",
      "width":"",
      "sortable":"false",
      "show_in_grid":1,
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":3,
      "header":"deleted",
      "dataIndex":"deleted",
      "width":"",
      "sortable":"false",
      "show_in_grid":"0",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    },
    {
      "MIGX_id":4,
      "header":"published",
      "dataIndex":"published",
      "width":"",
      "sortable":"false",
      "show_in_grid":"0",
      "renderer":"",
      "clickaction":"",
      "selectorconfig":"",
      "renderchunktpl":"",
      "renderoptions":"",
      "editor":""
    }
  ]
}


The database was created. When displaying TV there is a table in which I can add authors. I do not know how to implement adding each individual author from a table to a specific article from the container. Also, the table is not displayed at all with "check_resid": 1. In DB, after adding author, his resource_id - 0.

How can I resolve this problem? Thanks in advance!]]>
extrim25 Oct 17, 2017, 07:58 PM https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554599
<![CDATA[Re: Adding authors for articles]]> https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554769
You may also want to have your class extend xPDOSimpleObject, which will give it an autoincrement 'id' field.]]>
BobRay Oct 24, 2017, 10:33 PM https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554769
<![CDATA[Re: Adding authors for articles]]> https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554756 extrim25 Oct 24, 2017, 06:03 PM https://forums.modx.com/thread/103008/adding-authors-for-articles#dis-post-554756