Joomla component how to avoid refilling the passwo

2019-09-06 11:13发布

问题:

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