Created
April 2, 2015 21:27
-
-
Save reneighbor/8cdd78a76d227d080b95 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected function getPropertiesPartial($data, $includeParams = true) { | |
$template = $this->getTemplate('/scaffold/partials/properties.mustache'); | |
$template->set('resource', $this->context->getResourceKey()); | |
$template->set('serviceName', $this->service); | |
$sections = $this->context->getSections(); | |
$fields = $this->context->getFields($includeParams); | |
// draw fields that are part of seperate sections | |
foreach ($sections as $section) { | |
$sectionTable = $this->getSectionTable($data, $section, $fields); | |
$template->add('sectionTables', $sectionTable); | |
} | |
foreach ($fields as $key => $field) { | |
if (in_array($key, $this->drawnFields)) { | |
continue; | |
} | |
if (!$field['permissions']['expand']) { | |
continue; | |
} | |
// draw fields that are in list form in their own tables | |
if (static::isListProperty($key)) { | |
$title = substr($key, 0, strpos($key, '[]')); | |
$template->add('listTables', $this->getPropertiesTable($data, $title, $fields)); | |
continue; | |
} | |
// draw cells that are the default case | |
$cell = ScaffoldField::get($field, ScaffoldJQ::filter($data, '.'. $key)); | |
$template->add( | |
'properties', | |
array( | |
'name' => $field['name'], | |
'value' => $cell->render(), | |
) | |
); | |
$this->drawnFields[] = $key; | |
} | |
return $template->render(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment