Hi abolabo, i can't get the errors shown. And when it redirects, the existing data in the fields are gone, here are my codes:
public function onControllerPagesAccountCreate_InitData() {
$that=$this->baseObject;
$that->loadModel('telephone_option/customer');
$that->loadModel('account/customer');
$request_data = $that->request->post;
if ($that->request->is_POST()) {
//check your attributes (fields) first
$errors = $that->model_telephone_option_customer->validateRegister($that->request->post['telephone'],$that->request->post['fax'],$that->request->post['company']);
if(!empty($errors)){
$base_errors = $that->model_account_customer->validateRegistrationData($request_data);
//redirect for case when base form data is valid but custom attribute value does not
if(!$base_errors){
$this->errors=$errors;
$this->baseObject->log->write(var_export($errors,true));
header('Location: ' . $that->html->getURL('account/create'));
exit();
}
}
}
}
public function onControllerPagesAccountCreate_UpdateData() {
$that=$this->baseObject;
if ($this->baseObject_method='main') {
$phone = $that->config->get('phone_option_mandatory_status');
$fax = $that->config->get('fax_option_mandatory_status');
$company = $that->config->get('company_option_mandatory_status');
if($that->config->get('prevent_email_as_login')){
$this->data['noemaillogin'] = true;
}
$form = new AForm();
$form->setForm(array( 'form_name' => 'AccountFrm' ));
$this->data['form'][ 'form_open' ] = $form->getFieldHtml( array( 'type' => 'form',
'name' => 'AccountFrm',
'action' => $that->html->getSecureURL('account/create')));
if($that->config->get('prevent_email_as_login')){ // require login name
$this->data['form'][ 'loginname' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'loginname',
'value' => $that->request->post['loginname'],
'required' => true ));
}
$this->data['form'][ 'firstname' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'firstname',
'value' => $that->request->post['firstname'],
'required' => true ));
$this->data['form'][ 'lastname' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'lastname',
'value' => $that->request->post['lastname'],
'required' => true ));
$this->data['form'][ 'email' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'email',
'value' => $that->request->get_or_post('email'),
'required' => true ));
$phoneStatus=($phone=='1' ? true : false);
$this->data['form'][ 'telephone' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'telephone',
'value' => $that->request->post['telephone'],
'required' => $phoneStatus
));
$faxStatus=($fax=='1' ? true : false);
$this->data['form'][ 'fax' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'fax',
'value' => $that->request->post['fax'],
'required' => $faxStatus ));
$companyStatus=($company=='1' ? true : false);
$this->data['form'][ 'company' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'company',
'value' => $that->request->post['company'],
'required' => $companyStatus ));
$this->data['form'][ 'address_1' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'address_1',
'value' => $that->request->post['address_1'],
'required' => true ));
$this->data['form'][ 'address_2' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'address_2',
'value' => $that->request->post['address_2'],
'required' => false ));
$this->data['form'][ 'city' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'city',
'value' => $that->request->post['city'],
'required' => true ));
$this->data['form'][ 'postcode' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'postcode',
'value' => $that->request->post['postcode'],
'required' => true ));
$that->loadModel('localisation/country');
$countries = $that->model_localisation_country->getCountries();
$options = array("FALSE" => $that->language->get('text_select') );
foreach($countries as $item){
$options[ $item['country_id'] ] = $item['name'];
}
$this->data['form'][ 'country_id' ] = $form->getFieldHtml( array(
'type' => 'selectbox',
'name' => 'country_id',
'options'=>$options,
'value' => ( isset($that->request->post['country_id']) ? $that->request->post['country_id'] : $that->config->get('config_country_id')),
'required' => true ));
$that->view->assign('zone_id', $that->request->post['zone_id'], 'FALSE' );
$this->data['form'][ 'zone_id' ] = $form->getFieldHtml( array(
'type' => 'selectbox',
'name' => 'zone_id',
'required' => true ));
$this->data['form'][ 'password' ] = $form->getFieldHtml( array(
'type' => 'password',
'name' => 'password',
'value' => $that->request->post['password'],
'required' => true ));
$this->data['form'][ 'confirm' ] = $form->getFieldHtml( array(
'type' => 'password',
'name' => 'confirm',
'value' => $that->request->post['confirm'],
'required' => true ));
$newsletter = '';
$this->data['form'][ 'newsletter' ] = $form->getFieldHtml( array(
'type' => 'radio',
'name' => 'newsletter',
'value' => (!is_null($that->request->get_or_post('newsletter')) ? $that->request->get_or_post('newsletter') : -1),
'options' => array(
'1' => $that->language->get('text_yes'),
'0' => $that->language->get('text_no'),
) ));
$agree = isset($that->request->post['agree']) ? $that->request->post['agree'] : FALSE;
$this->data['form'][ 'agree' ] = $form->getFieldHtml( array(
'type' => 'checkbox',
'name' => 'agree',
'value' => 1,
'checked' => $agree ));
$this->data['form'][ 'continue' ] = $form->getFieldHtml( array(
'type' => 'submit',
'name' => $that->language->get('button_continue') ));
$this->data['error_warning'] = $this->errors['warning'];
$this->data['error_loginname'] = $this->errors['loginname'];
$this->data['error_firstname'] = $this->errors['firstname'];
$this->data['error_lastname'] = $this->errors['lastname'];
$this->data['error_email'] = $this->errors['email'];
$this->data['error_telephone'] = $this->errors['telephone'];
$this->data['error_fax'] = $this->errors['fax'];
$this->data['error_company'] = $this->errors['company'];
$this->data['error_password'] = $this->errors['password'];
$this->data['error_confirm'] = $this->errors['confirm'];
$this->data['error_address_1'] = $this->errors['address_1'];
$this->data['error_city'] = $this->errors['city'];
$this->data['error_postcode'] = $this->errors['postcode'];
$this->data['error_country'] = $this->errors['country'];
$this->data['error_zone'] = $this->errors['zone'];
$this->data['action'] = $that->html->getSecureURL('account/create') ;
$this->data['newsletter'] = $that->request->post['newsletter'];
if ($that->config->get('config_account_id')) {
$that->loadModel('catalog/content');
$content_info = $that->model_catalog_content->getContent($that->config->get('config_account_id'));
if ($content_info) {
$text_agree = $that->language->get('text_agree');
$this->data['text_agree_href'] = $that->html->getURL('r/content/content/loadInfo', '&content_id=' . $that->config->get('config_account_id'));
$this->data['text_agree_href_text'] = $content_info['title'];
} else {
$text_agree = '';
}
} else {
$text_agree = '';
}
$this->data['text_agree'] = $text_agree;
$text_account_already = sprintf($that->language->get('text_account_already'), $that->html->getSecureURL('account/login') );
$this->data['text_account_already'] = $text_account_already;
$that->view->batchAssign($this->data);
$that->processTemplate('');
}
}
I wonder if there are errors on my codes. Thanks