Form Handling and store the data

Hi Guys,

I have a query regarding form handling in oxid.
I want to extend register form with few extra fields. Like I have 2 radio buttons on main register form, When user clicks a particular radio button, an additional form data will be asked to fill up respective to radio btn. Now I want to store those data on different table using the same user ID when user press “SAVE” button.
As I have gone through oxcmp_user.php and register controller I could not find how to handle it.

Any kind of help or guidance is appreciated.

Thanks and Regards.

have a look at newsletter subscriptions during registration, there is a checkbox and the data is stored in different table, just like you need.
Get the checkbox name and find it’s occurencies in php soruce code.

Thanks @vanilla_thunder for yous suggestion but somehow I couldn’t find the code where it performs insertion operation to the table.
Here I have appended the part of code what I am doing but some how its not filling any data, I think I am missing something here like where it should indicate that create OXID to table and insert the form data on table.

 public function setbuserdata($aInbuser)
 {
     if (is_array($aInbuser) && count($aInbuser)) {

         $sbuserId = $this->getConfig()->getRequestParameter('oxbluserid');
         $sbuserId = ($sbuserId === null || $sbuserId == -1 || $sbuserId == -2) ? null : $sbuserId;

         $oBuser = oxNew('oxbuser');
         $oBuser->setId($sbuserId);
         $oSupp->load($sbuserId);
         $oSupp->assign($aInbuser);
         $oSupp->oxbuser__oxuserid = new oxField($this->getId(), oxField::T_RAW);
         $oSupp->save();

                 }
 }

Can anyone suggest something! would be great help.

Thanks

its a MVC pattern, data is saved into database when you call save() on your model.

Lets say, you created custom model class oxbuser, to map object properties to table columns you need to pass table name in model constructor, like its done here:

hi @vanilla_thunder, thanks for responding.

I have created it in same way but some how it throws sqli error
here is the code snippet:

{
protected $_sClassName = ‘oxbuser’;
protected $_coreTable = ‘oxbuser’;

// Constructor
public function __construct()
{
parent::__construct();
$this->init(‘oxbuser’);

}

here is the error which i gets on the page:

mysqli error: [1054: Unknown column ‘oxusername’ in ‘where clause’] in EXECUTE (SELECT oxid FROM oxbuserWHERE ( oxusername = ‘’ ) AND oxshopid = “oxbaseshop” , ) with user root

are you sure there is no other code involving your oxbuser model? any function calls? what class did you inherit from?

@vanilla_thunder There is a bit more and Its extending ‘oxuser’ class.
I have saveral function there. which i nedd to use for some manipulation

in this case there might be some side effects from original oxuser functions, that try to use database fields oxuser model uses, but your model does not have. You will have to adjust your table structure to oxuser

HI Everyone,

Thanks @vanilla_thunder, I have fixed the problem. I think the problem was due to the extension of ‘oxuser’ class. Now I am extending from ‘oxBase’ class and it works fine. Appreciate the support.