Joomla组件如何避免重新填写密码字段

时间:2013-11-21 10:06:27

标签: php joomla joomla2.5 joomla-component

protected function postSaveHook(JModel &$model, $validData = array())
{
    // Get a handle to the Joomla! application object
    $application = JFactory::getApplication();

    $date = date('Y-m-d H:i:s');
    if($validData['date_created'] == '0000-00-00 00:00:00'){
        $data['date_created'] = $date;
    }
    $data['date_modified'] = $date;

    $user = JFactory::getUser();
    if($validData['user_created'] == 0){
        $data['user_created'] = $user->id;
    }
    $data['user_modified'] = $user->id;
    //$password = md5($this->form->getValue('password'));
    //$data['password'] = $password;
    $post = JRequest::getVar('jform');
    $data['password'] = md5($post['password']);
    $model->save($data);

}

字段形式:

        <div class="adminformlist">
            <?php foreach($this->form->getFieldset('details') as $field){ ?>
                <div>
                    <?php echo $field->label; echo $field->input;?>
                </div>
                <div class="clr"></div>
            <?php }; ?>
        </div>

我在获取密码后将md5哈希保存到数据库,但是当我编辑该用户时,密码字段会重新填充md5哈希码,那么我该如何避免呢?

我需要密码字段为空,但字段是在foreach循环中填充的,我试图在xml中设置默认值,但它不起作用

joomla库非常庞大,我没有找到任何方法,也许有人知道吗?

joomla 2.5

0 个答案:

没有答案