gpt4 book ai didi

php - 节点更新 : getting the old value

转载 作者:可可西里 更新时间:2023-10-31 23:34:57 24 4
gpt4 key购买 nike

我正在使用 nodeapi update 更新一个节点,但是我需要在幕后做更多的事情,这需要我知道一个字段的旧值/有没有办法我可以在之前获取一个字段的旧值它被覆盖了。

最佳答案

编辑

hook_nodeapi() 只作用于新的 $node 对象,所以我之前的回答对你没有帮助。相反,您需要在提交节点时访问该节点。为此,您需要注册自己的提交处理程序,该处理程序将在提交节点表单时调用。它会让您访问当前值和新值:

function test_form_alter(&$form, &$form_state, $form_id) {
if ($form_id === 'contenttype_node_form') { // Replace contenttype
$form['#submit'][] = 'test_submit'; // Add a submit handler
}
}

function test_submit($form, &$form_state) {
// Load the current node object
$node = node_load($form_state['values']['nid']);

// Display the current node object's values
dsm($node);

// Display the submitted values
dsm($form_state['values']);
}

update 调用$node 对象已经更新。您可能对 presave 更感兴趣,它在验证后检查节点,或 validate,它在验证前检查它;在保存新的 $node 对象之前,两个 $op 都会触发。

关于php - 节点更新 : getting the old value,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3506990/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com