# MIGX with xPDOSimpleObject not creating id field in new table

**URL:** <https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898>\
**Category:** Support\
**Tags:** migx\
**Created:** [July 27, 2020, 1:56pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898 "2020-07-27T13:56:45Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpbouch](https://community.modx.com/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@mpbouch](https://community.modx.com/u/mpbouch)\
**Post date:** [July 27, 2020, 1:56pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/1 "2020-07-27T13:56:45Z")

</div>

I am using MIGX to create a table using the schema below (the \< has been omitted at the start of each line as difficult to copy and paste the code!).

Any reason for this as each of the other table fields are created?

```auto
<?xml version="1.0" encoding="UTF-8"?>
model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
object class="player" table="playerdetails" extends="xPDOSimpleObject">
field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
/object>
/model>

```

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 27, 2020, 2:27pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/2 "2020-07-27T14:27:45Z")

</div>

Have you tried using `"` instead of the `“` and `”`-characters?  
It works on my system with this code:

```auto
<?xml version="1.0" encoding="UTF-8"?>
<model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
	<object class="player" table="playerdetails" extends="xPDOSimpleObject">
		<field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
		<field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
		<field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
	</object>
</model>

```

---

<div class="post-metadata">

**Author:** ![mpbouch](https://community.modx.com/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@mpbouch](https://community.modx.com/u/mpbouch)\
**Post date:** [July 27, 2020, 3:24pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/3 "2020-07-27T15:24:17Z")

</div>

Thanks halftrainedharry  
I copied your code and used it but the new table did not have an id field.  
My keyboard only has the one " key so I don’t know what you are referring to.

I am using Modx 2.7.3 with PHP version 7.3.6 and Bootstrap template.

My system error log is:

[Mon Jul 27 07:03:07.187164 2020] [authz\_core:error] [pid 728156:tid 22524578150144] [client 173.254.29.24:55344] AH01630: client denied by server configuration: /home2/beacona1/public\_html/honours/core/docs/changelog.txt  
[Mon Jul 27 07:03:00.092902 2020] [authz\_core:error] [pid 717224:tid 22524636985088] [client 173.254.29.24:55270] AH01630: client denied by server configuration: /home2/beacona1/public\_html/honours/core/docs/changelog.txt  
[Mon Jul 27 03:51:34.318606 2020] [authz\_core:error] [pid 377376:tid 22524618073856] [client 173.254.29.24:38212] AH01630: client denied by server configuration: /home2/beacona1/public\_html/honours/core/docs/changelog.txt

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 27, 2020, 4:16pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/4 "2020-07-27T16:16:35Z")

</div>

- Are there any relevant errors in the modx error log?
- Is the line `'extends' => 'xPDOSimpleObject',` in the file `core/components/players/model/players/mysql/player.map.inc.php`?
- Have you change the schema, after you had already created the table in the database?
- Did you delete the table in the database before clicking the `"create Tables"`-button for a second time?

---

<div class="post-metadata">

**Author:** ![mpbouch](https://community.modx.com/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@mpbouch](https://community.modx.com/u/mpbouch)\
**Post date:** [July 27, 2020, 4:25pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/5 "2020-07-27T16:25:12Z")

</div>

Thanks halftrainedharry

The player.map.inc.php file is:

```auto
<?php
$xpdo_meta_map['player']= array (
  'package' => 'players',
  'version' => '1.1',
  'table' => 'playerdetails',
  'extends' => 'xPDOSimpleObject',
  'tableMeta' => 
  array (
    'engine' => 'MyISAM',
  ),
  'fields' => 
  array (
    'playername' => '',
    'gender' => '',
    'published' => 0,
  ),
  'fieldMeta' => 
  array (
    'playername' => 
    array (
      'dbtype' => 'varchar',
      'phptype' => 'string',
      'precision' => '100',
      'null' => false,
      'default' => '',
    ),
    'gender' => 
    array (
      'dbtype' => 'varchar',
      'phptype' => 'string',
      'precision' => '10',
      'null' => false,
      'default' => '',
    ),
    'published' => 
    array (
      'dbtype' => 'int',
      'phptype' => 'integer',
      'precision' => '1',
      'attributes' => 'unsigned',
      'null' => false,
      'default' => 0,
    ),
  ),
);

```

The modx error log is:

```auto
[2020-07-27 09:35:44] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:37:24] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:37:48] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 
[2020-07-27 09:42:47] (ERROR in modProcessor::run @ /home2/beacona1/public_html/honours/core/model/modx/modprocessor.class.php : 177) Flat file processor support, used for action mgr/migxdb/getList with path /home2/beacona1/public_html/honours/core/components/migx/processors/mgr/migxdb/getlist.php, is deprecated since version 2.7.0. 

```

Each time I have tried it I have deleted the table from the database before creating the table and I am using the schema you posted earlier.

Thanks for your help so far.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [July 27, 2020, 7:57pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/6 "2020-07-27T19:57:37Z")

</div>

No idea what the problem is. It all looks good to me!  
More as a workaround than a solution you could try this schema, where `xPDOSimpleObject` isn’t used and the column `id` is defined directly in the schema.

```auto
<?xml version="1.0" encoding="UTF-8"?>
<model package="players" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">	
	<object class="player" table="playerdetails" extends="xPDOObject">
		<field key="id" dbtype="int" precision="10" attributes="unsigned" phptype="integer" null="false" index="pk" generated="native" />
		<field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" />
		<field key="gender" dbtype="varchar" phptype="string" precision="10" null="false" default="" />
		<field key="published" dbtype="int" phptype="integer" precision="1" attributes="unsigned" null="false" default="0" />
		
		<index alias="PRIMARY" name="PRIMARY" primary="true" unique="true">
			<column key="id" collation="A" null="false" />
		</index>
	</object>
</model>

```

---

<div class="post-metadata">

**Author:** ![mpbouch](https://community.modx.com/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@mpbouch](https://community.modx.com/u/mpbouch)\
**Post date:** [January 14, 2021, 1:45pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/7 "2021-01-14T13:45:33Z")

</div>

I am now back on the project.

I have two custom tables, one for players and another for the honours they have achieved in a club. I am trying to use a list box from the players table with a list of players to select the one I want to use to create a record in the honours table.

I am using formit and migxloopcollection as a select tool. However, when I try to create an honours record the name does not get selected, a 0 is input into the playername field.

The migxloopcollection select tlpoption was suggested by halftrainedharry some months ago.

The resource code is.  
[[!FormIt?  
&hooks=`formit2db,redirect`  
&preHooks=`db2formit`  
&prefix=`agc_`  
&packagename=`honours`  
&classname=`honposition`  
&tablename=`positionagc`  
&redirectTo=`5`  
&store=`1`  
&validate=`nospam:blank, playername:required, position:required, yearwhen:required`  
]]

## Add Position Form
[[!+fi.successMessage]] [[!+fi.validation\_error\_message:notempty=`

[[!+fi.validation\_error\_message]]

`]] Select position... Mens Captain Ladies Captain President Vice President
Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &sortConfig=`[{"sortby":"surname"}]` &where=`{"gender":"1"}` &selected=`[[!+fi.playername]]` ]]

Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &where=`{"gender":"2"}` &selected=`[[!+fi.playername]]` ]]

Select member ... [[!migxLoopCollection? &prefix=`agc_` &usecustomprefix=`agc_` &packageName=`honours` &classname=`player` &selectfields=`fullname,gender` &tpl=`tplOption` &selected=`[[!+fi.playername]]` ]]
 Year Captain: [[!+fi.error.yearwhen]]  

```
<div class="form-buttons">
    <input type="submit" value="Enter captain details" />
</div>

```

The tplOption is.

```
    <option value="[[+fullname]]" [[+fullname:eq=`[[+property.selected]]`:then=` selected="[[+fullname]]"`]]>[[+fullname]]</option>

```

The schema is:  
`<?xml version="1.0" encoding="UTF-8"?> <model package="honours" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1"> <object class="player" table="playerdetails" extends="xPDOSimpleObject"> <field key="timeset" dbtype="varchar" phptype="string" precision="25" null="false" default="" /> <field key="title" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial1" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial2" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="initial3" dbtype="varchar" phptype="string" precision="10" null="false" default="" /> <field key="surname" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="fullname" dbtype="varchar" phptype="string" precision="50" null="false" default="" /> <field key="gender" dbtype="int" phptype="string" precision="1" null="false" default="" /> <composite alias="captain" class="captain" local="fullname" foreign="playername" cardinality="many" owner="local"/> </object> <object class="honposition" table="positionagc" extends="xPDOSimpleObject"> <field key="playername" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="position" dbtype="int" phptype="string" precision="1" null="false" default="" /> <field key="yearwhen" dbtype="int" phptype="integer" precision="10" null="false" default="0" /> <aggregate alias="player" class="player" local="playername" foreign="fullname" cardinality="one" owner="foreign" /> </object> <object class="competition" table="competitionagc" extends="xPDOSimpleObject"> <field key="compname" dbtype="varchar" phptype="string" precision="100" null="false" default="" /> <field key="comptype" dbtype="int" phptype="string" precision="1" null="false" default="" /> <field key="compdesc" dbtype="text" phptype="string" precision="500" null="false" default="0" /> </object> </model>`

Any help would be useful.

---

<div class="post-metadata">

**Author:** ![halftrainedharry](https://community.modx.com/user_avatar/community.modx.com/halftrainedharry/32/1063_2.png) [@halftrainedharry](https://community.modx.com/u/halftrainedharry)\
**Post date:** [January 14, 2021, 2:19pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/8 "2021-01-14T14:19:28Z")

</div>

It would be helpful, if you could put a line with 3 back-ticks at the start and the end of every code block (especially the one with the form), so everything is formatted correctly.

````auto
```//line with 3 back-ticks at the beginning
//your code here
```//line with 3 back-ticks at the end

````

---

<div class="post-metadata">

**Author:** ![bruno17](https://community.modx.com/user_avatar/community.modx.com/bruno17/32/71_2.png) [@bruno17](https://community.modx.com/u/bruno17)\
**Post date:** [January 14, 2021, 2:55pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/9 "2021-01-14T14:55:37Z")

</div>

could you solve your initial issue? Seems this is a new question now.  
If so, describe how you solved it and start a new thread, please.

---

<div class="post-metadata">

**Author:** ![mpbouch](https://community.modx.com/letter_avatar_proxy/v4/letter/m/c57346/32.png) [@mpbouch](https://community.modx.com/u/mpbouch)\
**Post date:** [January 14, 2021, 4:20pm UTC](https://community.modx.com/t/migx-with-xpdosimpleobject-not-creating-id-field-in-new-table/2898/10 "2021-01-14T16:20:18Z")

</div>

Thanks Bruno.  
I reinstalled migx and now it creates tables correctly with an id field.  
Do I need to copy my previous post into a new post now?
