This question is based on how FormLister works when trying to use this tutorial https://forum.evo.im/d/82-formlister-create-multiple-select-options-using-doclister.
I've created a page which works great but it has one issue. My code produces a form which has a radio option which is built from children in a parent document.
The children are published and hidden but I thought a tidier way would be to have them unpublished so the page cannot be gotten to at all.
The issue I have is the FormLister parameter addWhereList. When it comes to "published" I cannot get it to work. I know why. The FormLister snippet automatically has c.published = 1 as a WHERE clause. So having addwherelist with published=0 won't work.
How do I make it work?
Here's my render snippet for FormLister:
<?php
$user = $modx->getWebUserInfo($modx->getLoginUserID());
//$modx->logEvent(0, 1, "user {$user['fullname']} is missing", 'FormListerPrepare');
$values = $FormLister->getField('person');
if (!is_array($values)) {
$values = empty($values) ? [] : [$values];
}
$options = $modx->runSnippet('DocLister', [
'parents' => [784],
'orderBy' => 'pagetitle ASC',
'tvList' => 'number',
'renderTV' => 'number',
'addWhereList' => 'published=1',
'tpl'=>'@CODE:<li><input id="person-[+id+]" name="person[]" type="radio" value="[+title+]" [+checked+] />[+title+]</li>',
'prepare' => function($data) use ($values){
$value = "{$data['pagetitle']}";
$modx = EvolutionCMS();
$user = $modx->getWebUserInfo($modx->getLoginUserID());
$value = $user['fullname'];
//$modx->logEvent(0, 1, "user {$user['fullname']} is not {$values}", 'FormListerPrepare');
$data['checked'] = in_array($value, $values) ? 'checked' : '';
return $data;
}
]);
$FormLister->setPlaceholder('radioPerson', $options);
Does anyone have any ideas how to make it work with unpublished documents?