-
-
Save guelu63/54c137fdbdbc5aff10c0569b27b34baa 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
<?php | |
$doc = $modx->newObject('modResource'); | |
$doc->set('createdby', $modx->user->get('id')); | |
$allFormFields = $hook->getValues(); | |
foreach ($allFormFields as $field=>$value) | |
{ | |
$doc->set($field, $value); | |
} | |
$doc->set('parent', '64'); | |
$doc->set('alias', mktime()); | |
$doc->set('template', '4'); | |
$doc->set('published', '0'); | |
$doc->save(); | |
foreach ($allFormFields as $field=>$value) | |
{ | |
if ($tv = $modx->getObject('modTemplateVar', array ('name'=>$field))) | |
{ | |
/* handles checkboxes & multiple selects elements */ | |
if (is_array($value)) { | |
$featureInsert = array(); | |
while (list($featureValue, $featureItem) = each($value)) { | |
$featureInsert[count($featureInsert)] = $featureItem; | |
} | |
$value = implode('||',$featureInsert); | |
} | |
$tv->setValue($doc->get('id'), $value); | |
$tv->save(); | |
} | |
} | |
return true; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment