PubKit CreatePlayer input form
The PubKit snippet call for a custom-table record looks like this (using the Player class as an example):
[!PubKit?class=`player` &formtpl=`pk.orch.input.tpl` &tvs=`pkSection,section,section,pkSection;pkProfi,pro,pro`
&postid=`pkdemo-orchestra` &debug=`0`!]
The HTML chunk for adding a new Player item or editing an existing one is listed below. This can be a chunk specified by its name, or a file specified using &formtpl=`@FILE:orch`, where the file is stored in the pubKit/chunks folder with a name in the format chunk.orch.html.
Note that this record makes use of a tagging TV, pkSection, which is a drop-down selection list. Since the OptionButtons class, which turns the TV into HTML for the page, reads its definition from the database, there is no need for the TV to be attached to a MODx resource. A second TV, the pkProfi checkbox, is also attached to the item via the snippet parameter.
When you click on Delete in the Manage or Preview screens, the output of the PubKit snippet will be the template chunk pk.item.delete.tpl. The class's constructor function sets up the prompt message in the appropriate language and the player's name in the delMsg placeholder.
pk.orch.input.tpl
[+errors+]
<input name="pkForm" type="hidden" value="on" />
<input name="docId" type="hidden" value="[+docId+]" />
<input name="returnId" type="hidden" value="[+returnId+]" />
<div class="row"><span class="edLabel"> <label for="player">Name</label></span>
<span class="edField"> <input class="wide" id="player" name="player" value="[+player+]" type="text"> </span>
</div>
<div class="row"><span class="edLabel"> <label for="instrument">Instrument</label></span>
<span class="edField"> <input class="wide" id="instrument" name="instrument" value="[+instrument+]" type="text"> </span>
</div>
<div class="row">
<span class="edLabel"> <label for="tags">Section</label></span> [+section+]
<span class="edLabelsubs"><label for="rank">Position</label>
<input type="text" size="2" name="rank" id="rank" value="[+rank+]" /></span>
<span class="edLabelsubs"><label for="pro">Professional</label></span>[+pro+]
</div>
<div class="row"><input class="subButton" name="submit" value="Submit" accesskey="B" type="submit">
</div>
</form>
Confirm deletion template chunk
named in the item's class definition, e.g.
var $delForm = 'pk.PlayerDelete.tpl';
made specific to the individual record in the class's constructor function:
$this->delMsg = $this->lang['del_player'] . chr(32) .
$this->player;
<input name="confirmDeletion" type="hidden" value="on" />
<input type="hidden" name="docId" value="[+docId+]">
<input type="hidden" name="returnId" value="[+returnId+]">
<p> Delete [+delMsg+] </p>
<input name="delete" type="submit" value="Yes" />
<input name="erase" type="submit" value="No" />
</form>