/**
* Load properties from document type, tab and document
*
* @param integer $documentTypeId Document type id
* @param DocumentModel $document Document model
* @param ServiceManager $serviceLocator Service manager
*
* @return array
*/
public function load($documentTypeId, DocumentModel $document, ServiceManager $serviceLocator)
{
$tabs = $this->loadTabs($documentTypeId);
$tabsArray = array();
$idx = 1;
foreach ($tabs as $tab) {
$tabsArray[] = $tab->getName();
$properties = $this->loadProperties($documentTypeId, $tab->getId(), $document->getId());
$fieldset = new ZendForm\Fieldset('tabs-' . $idx);
foreach ($properties as $property) {
$elements = AbstractForm::addContent($fieldset, Datatype\Model::loadEditor($serviceLocator, $property));
if (!is_array($elements)) {
$elements = array($elements);
}
foreach ($elements as $element) {
if (empty($element)) {
continue;
}
$element->setOption('required', $property->isRequired());
$element->setOption('description', $property->getDescription());
}
}
$this->add($fieldset);
$idx++;
}
$formDocumentAdd = new DocumentInformation();
$formDocumentAdd->load($document, $serviceLocator->get('Config'));
$formDocumentAdd->setAttribute('name', 'tabs-' . $idx);
$this->add($formDocumentAdd);
return $tabsArray;
}