-
☆ A M B ☆
- 209 Posts
Doesn't work sadly (I removed the extra parentheses on line 7), it still hangs on save.
Ben Morrison
Hacking templates to pieces since 2003
discuss.answer
switch ($modx->event->name) {
case 'OnDocFormSave':
$created_by = $resource->getTVValue('setCreatedBy');
if (!empty($created_by) && $resource->get('createdby') != $created_by) {
$resource->set('createdby', $created_by);
$resource->save();
}
break;
}
[ed. note: Bruno17 last edited this post 12 years, 5 months ago.]
-
☆ A M B ☆
- 209 Posts
Thanks Bruno, it certainly doesn't hang anymore but it doesn't change the createdby field. I'm using [[*createdby]] tag to check.
Ben Morrison
Hacking templates to pieces since 2003
This definitely should work. Just tested it.
-
☆ A M B ☆
- 209 Posts
I checked all the settings, the plugin is set to fire on onDocFormSave, the cache was cleared after the change just to be sure. Could it have anything to do with the @EVAL binding I used to populate the original TV?
@EVAL return $modx->runSnippet('Peoples',array('tpl'=>'peoplesTpl','outputSeparator'=>'||','active'=>'1'));
peoplesTpl:
I know I am missing something.
Ben Morrison
Hacking templates to pieces since 2003
the TV - setup looks good
this is the correct TV - name?
do you get the correct value with
-
☆ A M B ☆
- 209 Posts
I get the right value from:
Just not from:
The name of the TV is correct.
Ben Morrison
Hacking templates to pieces since 2003
does GridClassKey do something differently here, than a normal resource?
-
☆ A M B ☆
- 209 Posts
I have been using a resource outside of GridClassKey to prevent that from happening. It is just a standard resource.
Ben Morrison
Hacking templates to pieces since 2003
should be
corrected my posts above, too
also, because its only one system-event, you wouldn't need the system-event - switch