Joomla component how to avoid refilling the password field

霸气de小男生 提交于 2019-12-11 14:06:10

问题


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);

}

the fields form:

        <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>

I'am saving an md5 hash to the database after getting the password, but when I'am editing that user the password field is refilled with the md5 hash code, so how can I avoid that?

I need the password field empty, but the fields are filled in foreach loop, I've tried to set the default value in the xml, but it didn't work

the joomla library is very huge, I didn't find any methods to that, maybe someone knows?

joomla 2.5

来源:https://stackoverflow.com/questions/20117846/joomla-component-how-to-avoid-refilling-the-password-field

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!