AbanteCart Community
AbanteCart Development => Customization help => Topic started by: Riin on June 15, 2014, 08:57:46 AM
-
How can I make "Company" a required field, both in the registration page and the guest checkout step 1 page?
-
Hello.
See code changes instructions:
Edit file:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/account/create.php
line: 160
$this->data['form'][ 'company' ] = $form->getFieldHtml( array(
'type' => 'input',
'name' => 'company',
'value' => $this->request->post['company'],
'required' => false ));
Change required to true
Now you need to add error validation and text in the model:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/model/account/customer.php
Look for function line 268 :
public function validateRegistrationData( $data ) {
Similar change guest checkout:
https://github.com/abantecart/abantecart-src/blob/master/public_html/storefront/controller/pages/checkout/guest_step_1.php
-
The first change was easy. The second one I'm having trouble with. I added this:
if ((mb_strlen($data['company']) < 3) || (mb_strlen($data['company']) > 128)) {
$error['company'] = $this->language->get('error_required');
}
to customer.php (error_required is defined in language definitions), but when I try to create an account and leave the company name blank it doesn't give me an error. What am I missing?
-
Anyone?
-
The first change was easy. The second one I'm having trouble with. I added this:
if ((mb_strlen($data['company']) < 3) || (mb_strlen($data['company']) > 128)) {
$error['company'] = $this->language->get('error_required');
}
to customer.php (error_required is defined in language definitions), but when I try to create an account and leave the company name blank it doesn't give me an error. What am I missing?
I still need to resolve this. Can someone please help?