News:

AbanteCart v1.4.2 is released.

Main Menu

how can I make company name required?

Started by Riin, June 15, 2014, 08:57:46 AM

Previous topic - Next topic

Riin

How can I make "Company" a required field, both in the registration page and the guest checkout step 1 page?

abantecart

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


Riin

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?


Riin

Quote from: Riin on June 15, 2014, 03:32:27 PM
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?

Forum Rules Code of conduct
AbanteCart.com 2010 -