Skip to content

Commit

Permalink
2028 - Working with tags, categories, and handling multi value fields…
Browse files Browse the repository at this point in the history
… correctly for regular non-custom fields
  • Loading branch information
rowasc committed Sep 11, 2017
1 parent 18c5902 commit c4b0fdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
7 changes: 4 additions & 3 deletions application/classes/Ushahidi/Formatter/Post/CSV.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,10 +79,11 @@ protected function generateCSVRecords($records)
$setValue = isset($recordVal[$headingKey][$keySet[1]])? ($recordVal[$headingKey][$keySet[1]]): '';
}
} else{
if (is_array($record[$headingKey]) && empty($record[$headingKey])) {
$record[$headingKey] = '';
if ( !isset($record[$headingKey]) || (is_array($record[$headingKey]) && empty($record[$headingKey]))) {
$setValue = '';
} else {
$setValue = $record[$headingKey];
}
$setValue = isset($record[$headingKey]) ? $record[$headingKey] : '';
}
$values[] = $setValue;
}
Expand Down
19 changes: 10 additions & 9 deletions application/classes/Ushahidi/Repository/Post/Export.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,19 +24,20 @@ public function retrieveColumnNameData($data) {
$attributes = [];
foreach ($data['values'] as $key => $val)
{
$attribute = $this->form_attribute_repo->getByKey($key);
/**
* @DEVNOTE form_stage_id can be NULL. Why is that? solve that scenario and get back here.
*/
$attributes[$key] = ['label' => $attribute->label, 'priority'=> $attribute->priority, 'stage' => $attribute->form_stage_id, 'type'=> $attribute->type];
$attribute = $this->form_attribute_repo->getByKey($key);
/**
* @DEVNOTE form_stage_id can be NULL. Why is that? solve that scenario and get back here.
*/
$attributes[$key] = ['label' => $attribute->label, 'priority'=> $attribute->priority, 'stage' => $attribute->form_stage_id, 'type'=> $attribute->type];

// Set attribute names
if ($attribute->type === 'tags') {
$data['values'][$key] = $this->retrieveTagNames($val);
}
}

$data += ['attributes' => $attributes];

// Set attribute names
if ($attribute->type === 'tags') {
$data['values'][$key] = $this->retrieveTagNames($val);
}

// Set Set names
if (!empty($data['sets'])) {
Expand Down

0 comments on commit c4b0fdd

Please sign in to comment.