<![CDATA[ tmplvars on OnBeforeDocFormSave - My Forums]]> https://forums.modx.com/thread/?thread=35173 <![CDATA[Re: tmplvars on OnBeforeDocFormSave]]> https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-547403
$tvValue = $resource->getTVValue($tvNameOrID);
$resource->set('someField', $tvValue);


If it's not available that way, put this at the top:

$id = $resource->get('id');


Because of the way TVs are stored, I'm not sure the $tmplvars array is reliable, and anyway, it could disappear or be changed in future versions. getTVValue() should always work.

If it's a new doc, it won't have any TV values.]]>
BobRay Dec 16, 2016, 09:01 PM https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-547403
<![CDATA[Re: tmplvars on OnBeforeDocFormSave]]> https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-192870
This block are work in 1.0.5

<?

global $tmplvars;
$e = &$modx->Event;
if ($e->name == 'OnBeforeDocFormSave'){
print_r ($tmplvars);
$modx->messageQuit('Debug stopping');
}
?>


Output
Array
(
    [22] => Array
        (
            [0] => 22
            [1] => запонка
        )

    [15] => Array
        (
            [0] => 15
            [1] => 01.01
        )

    [1] => Array
        (
            [0] => 1
            [1] => 7410
        )

    [18] => Array
        (
            [0] => 18
            [1] => есть
        )

    [promo] => 16
    [17] => Array
        (
            [0] => 17
            [1] => 17,46 г
        )

    [19] => Array
        (
            [0] => 19
            [1] => assets/images/collections/nature/ladybug/01.01/IMG_01_c.jpg
        )

    [21] => Array
        (
            [0] => 21
            [1] => assets/images/collections/nature/ladybug/01.01/IMG_01-p.png
        )

    [9] => Array
        (
            [0] => 9
            [1] => серебро
        )

    [3] => Array
        (
            [0] => 3
            [1] => золото
        )

    [2] => Array
        (
            [0] => 2
            [1] => коралл||кристаллы Сваровски
        )

    [4] => Array
        (
            [0] => 4
            [1] => [["assets/images/collections/nature/ladybug/01.01/IMG_01.jpg",""],["assets/images/collections/nature/ladybug/01.01/IMG_02.jpg",""],["assets/images/collections/nature/ladybug/01.01/IMG_03.jpg",""],["assets/images/collections/nature/ladybug/01.01/IMG_04.jpg",""],["assets/images/collections/nature/ladybug/01.01/IMG_05.jpg",""]]
        )

)


For manual writing to current page TV use
$tmplvars[$TVID][0] = $TVID;
$tmplvars[$TVID][1] = 'TV value post here';


// I know that this topic is old but I can’t find correct info about this problem, so better if this reply google will save]]>
Masterkey_SCR Jul 13, 2011, 07:11 AM https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-192870
<![CDATA[tmplvars on OnBeforeDocFormSave]]> https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-192869
But I can’t get the TVs available in the event [tt]OnBeforeDocFormSave[/tt], where I can change the docvars.

OnBeforeDocFormSave:
<?php
global $tmplvars;

print_r ($tmplvars);

$modx->messageQuit('Debug stopping');


This plugin gives me [tt]Array ( )[/tt] as a [tt]print_r[/tt] result.

That means that [tt]$tmplvars[/tt] is already defined as Array, which happens in [tt]save_content.processor.php #130[/tt], but has no elements inside, though they are perfectly collected in lines 173-181. And calls to OnBeforeDocFormSave happen only at #235 for the new document and #416 for the updated.

Where do the contents of [tt]$tmplvars[/tt] disappear?
]]>
almays Jul 06, 2007, 04:55 PM https://forums.modx.com/thread/35173/tmplvars-on-onbeforedocformsave#dis-post-192869