Need your help and creativity...
How would I go to detect when an option is unchecked on a
checkbox TV?
I can get the output of the TV which gives me the checked options,
but no clue on how to get what the user/editor unchecked from the
list to process further...
THanks in advance...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
you can try it with something like that:
<?php
case 'OnBeforeDocFormSave':
$tvid='21';
$tv=$modx->getTemplateVar($tvid,'*',$_POST['id']);
$elements=explode('||',$tv['elements']);
$uncheckedoptions=array();
foreach($elements as $element){
if (!in_array($element,$_POST['tv'.$tvid])){
$uncheckedoptions[]=$element;
}
}
//print_r($uncheckedoptions);
//die();
break;
Thanks Bruno17, OK, a plugin, I was thinking of using one but I have never used
one before... but I will learn to write one.
I was thinking of using OnBeforeTVFormSave, but I guess is the same
as I assume the TVForm is saved before the DocForm.
So let me see, get the status of options in TV just before saving,
explode options and put in $elements, check to see if each element
is in the array $_POST[’tv’.$tvid] --- what is this array? tv21?
probably will use getTemplateVarOutput instead ...
if it is not in the array, put in $uncheckedoptions.
Thanks this will work with very few tweaks, just dont know
what is the POST stuff doing...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner
U can add a plugin: OnDocFormSave
$TV = $modx->getTemplateVar(’mytvname’, "", $id);
if ($TV[’value’] == 1)
{
//Blah the checkbox is set....
} else
{
//Blah the checkbox is not set....
}
U must create a TV that has 1 as its default val.
Is this what u want?
Yes thanks, kinda. Actually I modified what bruno posted to process
the unchecked options. Remember that it is a multi checkbox, so
needs to be processed as a multidimensional array.
Then based on those results I do something like you suggest to
flag the members that have been unchecked...
Website: www.mercologia.com
MODX Revo Tutorials: www.modxperience.com
MODX Professional Partner