Jump to content

How to add a new field in the homepage registration?


ed0522

Recommended Posts


<?php

class AuthController extends AuthControllerCore

{

 

 

protected function processSubmitCreate()

{

 

$customer = new Customer();

$customer->nickname =Tools::getValue('nickname');

parent::processSubmitCreate();

}

 

}

 


I wrote codes like this, but I don't know how to save the value in to the object model. I tried to load the Customer.php use require(), but it showed faults.

 

Could somebody help me? I'm still confusing how the object model works here. I know how to build object model in a module. But here seems different.

Image 001.bmp

Edited by ed0522 (see edit history)
Link to comment
Share on other sites

Hi,

 

You have to modify class Customer to add new public var like name your input, and add item in array definition like below
 
public $newItemName;

	public static $definition = array(
		'table' => 'customer',
		'primary' => 'id_customer',
		'fields' => array(
			...
'newItemName' =>array('type' => self::TYPE_STRING),
		),
	);

Next you have to modify table customer to add new column  in your database.
 
Then you can add Code to save or update everywhere you want with code  like bellow:

 

$customer = new Customer();
$customer->newItemName=Tools::getValue('newItemName');
$customer->save();

 

 

Link to comment
Share on other sites

I added public var and filed in customer class.  This is my codes.

 

<?php

class AuthController extends AuthControllerCore

{

 

protected function processSubmitCreate()

{

 

$customer = new Customer();

$customer->nickname=Tools::getValue('nickname');

$customer->save();

 

 

}

}

 

but it shows mistake like this:

TECHNICAL ERROR: unable to load form. Details: Error thrown: [object Object] Text status: error
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...