Skip to content

Commit

Permalink
Accept an array of tags
Browse files Browse the repository at this point in the history
While the tag list field always returned string (parameter pool) and array values (XML) in the output, it did only accept a string of tags on post. This commit extends the field to accept an array of tags as well which is helpful, if you are building a tag list widget on the front-end and would like to post back to the system.

This change is supposed to be backwards compatible (it doesn't change the behaviour for posted string values).
  • Loading branch information
nilshoerrmann committed Jun 16, 2016
1 parent cf90c7a commit 189b387
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions symphony/lib/toolkit/fields/field.taglist.php
Original file line number Diff line number Diff line change
Expand Up @@ -397,8 +397,10 @@ public function checkPostFieldData($data, &$message, $entry_id = null)
}

if ($this->get('validator')) {
$data = preg_split('/\,\s*/i', $data, -1, PREG_SPLIT_NO_EMPTY);
$data = array_map('trim', $data);
if (!is_array($data)) {
$data = preg_split('/\,\s*/i', $data, -1, PREG_SPLIT_NO_EMPTY);
}
$data = array_filter(array_map('trim', $data));

if (empty($data)) {
return self::__OK__;
Expand All @@ -416,8 +418,11 @@ public function checkPostFieldData($data, &$message, $entry_id = null)
public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null)
{
$status = self::__OK__;
$data = preg_split('/\,\s*/i', $data, -1, PREG_SPLIT_NO_EMPTY);
$data = array_map('trim', $data);

if (!is_array($data)) {
$data = preg_split('/\,\s*/i', $data, -1, PREG_SPLIT_NO_EMPTY);
}
$data = array_filter(array_map('trim', $data));

if (empty($data)) {
return null;
Expand Down Expand Up @@ -692,7 +697,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = fal
$negation = true;
$null = true;
}

foreach ($data as &$value) {
$value = $this->cleanValue($value);
}
Expand All @@ -703,7 +708,7 @@ public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = fal
$joins .= " LEFT JOIN `tbl_entries_data_$field_id` AS `t{$field_id}_{$this->_key}` ON (`e`.`id` = `t{$field_id}_{$this->_key}`.entry_id) ";
$where .= " AND (
t{$field_id}_{$this->_key}.value $condition '$bit''
OR t{$field_id}_{$this->_key}.handle $condition '$bit''
OR t{$field_id}_{$this->_key}.handle $condition '$bit''
)";

if ($null) {
Expand Down

0 comments on commit 189b387

Please sign in to comment.