Skip to content

Commit

Permalink
Fixed data storage for backend tag fields
Browse files Browse the repository at this point in the history
Removed isTag parameter for backend tag fields to use the dca field as tag storage because this approach has never been implemented so far
  • Loading branch information
hschottm committed Oct 9, 2020
1 parent 42c6fc8 commit 92469a4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 22 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,6 @@ During the validation in the save process the tags module automatically saves th
| Key | Value | Description |
| ---------- |-------------| -----|
| table | Source table `string` | Name of the source table of the tag data. Default is the name of the actual DCA data container. |
| isTag | true/false `boolean` | If true (default) the tags will be saved in a separate tag table (tl_tags). If false, the content of the tag field will be saved in the associated database field of the data container. In this case you'll need more than a char(1) database field. |
| isTag | Count `integer` | The maximum number of tags that should be shown above the input field. This may be helpful if you have a large number of tags. If the maximum number is lower than the number of all tags, the component takes the tags with the most selections first and hides tags which are used rarely. |
| maxtags | Count `integer` | The maximum number of tags that should be shown above the input field. This may be helpful if you have a large number of tags. If the maximum number is lower than the number of all tags, the component takes the tags with the most selections first and hides tags which are used rarely. |


15 changes: 4 additions & 11 deletions classes/TagField.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

class TagField extends \TextField
{
protected $blnSubmitInput = FALSE;
protected $blnSubmitInput = true;
protected $strTagTable = "";
protected $intMaxTags = 0;

Expand All @@ -23,7 +23,7 @@ class TagField extends \TextField
*/
protected function saveTags($value)
{
if (!$this->blnSubmitInput)
if ($this->blnSubmitInput)
{
$this->import('Database');
$this->Database->prepare("DELETE FROM tl_tag WHERE from_table = ? AND tid = ?")
Expand Down Expand Up @@ -66,9 +66,6 @@ public function __set($strKey, $varValue)
{
switch ($strKey)
{
case 'isTag':
$this->blnSubmitInput = !$varValue;
break;
case 'table':
$this->strTagTable = $varValue;
break;
Expand All @@ -94,14 +91,11 @@ public function __get($strKey)
{
switch ($strKey)
{
case 'isTag':
return !$this->blnSubmitInput;
break;
case 'table':
return strlen($this->strTagTable) ? $this->strTagTable : $this->strTable;
break;
case 'value':
return $this->varValue;
return '';
break;
case 'maxtags':
return $this->intMaxTags;
Expand Down Expand Up @@ -130,7 +124,7 @@ public function generate()
$list .= '</li> ';
}
$list .= '</ul></div>';
$value = (!$this->blnSubmitInput) ? $this->readTags() : $this->varValue;
$value = $this->readTags();
return $list.sprintf('<input type="text" name="%s" id="ctrl_%s" class="tl_text%s" value="%s"%s onfocus="Backend.getScrollOffset();" />',
$this->strName,
$this->strId,
Expand All @@ -149,4 +143,3 @@ public function validate()
parent::validate();
}
}

12 changes: 3 additions & 9 deletions classes/TagFieldMemberFrontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
*/
class TagFieldMemberFrontend extends \FormTextField
{
protected $blnSubmitInput = FALSE;
protected $blnSubmitInput = true;
protected $strTagTable = "";
protected $intMaxTags = 0;

Expand All @@ -31,7 +31,7 @@ class TagFieldMemberFrontend extends \FormTextField
*/
protected function saveTags($value)
{
if (!$this->blnSubmitInput)
if ($this->blnSubmitInput)
{
$this->import('FrontendUser', 'User');
$this->import('Database');
Expand Down Expand Up @@ -71,9 +71,6 @@ public function __set($strKey, $varValue)
{
switch ($strKey)
{
case 'isTag':
$this->blnSubmitInput = !$varValue;
break;
case 'table':
$this->strTagTable = $varValue;
break;
Expand All @@ -99,9 +96,6 @@ public function __get($strKey)
{
switch ($strKey)
{
case 'isTag':
return !$this->blnSubmitInput;
break;
case 'table':
return strlen($this->strTagTable) ? $this->strTagTable : $this->strTable;
break;
Expand Down Expand Up @@ -146,7 +140,7 @@ public function generate()
$list .= '</li> ';
}
$list .= '</ul></div>';
$value = (!$this->blnSubmitInput) ? $this->readTags() : $this->varValue;
$value = $this->readTags();
return sprintf($list.'<input type="%s" name="%s" id="ctrl_%s" class="text%s%s" value="%s"%s%s',
$this->type,
$this->strName,
Expand Down

0 comments on commit 92469a4

Please sign in to comment.