8
« on: March 14, 2017, 06:03:28 PM »
Hello again!
I am stucked again at another point developing my extension.
Now I need to hook up some new fields to Address Book form.
I've managed to hook up my code in registration form when user is registering the login for 1st time. Like this:
public function onControllerPagesAccountCreate_UpdateData()
{
$that = $this->baseObject;
if ($that->request->is_POST())
{
...
$address_id = $result->rows[0]['address_id'];
$that->db->query(
sprintf("INSERT INTO `%s` (`address_id`, `address_complement`, `address_number`, `address_district`) VALUES (%d, '%s', '%s', '%s') ",
'pse_addresses_attributes',
$address_id,
$request_data['complement'],
$request_data['number'],
$request_data['district'])
);
}
...
}
My problem now is how can I determine the $address_id when adding new address from Address Book?
At Address Book edit page there is a button called "New Address" and it triggers the insert method at ControllerPagesAccountAddress class.
For some strange reason I do not understand the method addAddress from ModelAccountAddress class (called by insert method) does not set any address_id global variable.
So how can I get the address id latter in my hook function?
I have tried this with out success:
public function onControllerPagesAccountAddress_ProcessData()
{
$that = $this->baseObject;
$method = $this->baseObject_method;
$request_data = $that->request->post;
if ($method == 'insert') $address_id = $that->db->getLastId(); // This do not work!!
...
}
----
P.S.: Sorry about the code off the tags, but the forum is blocking me from posting code inside apropriate tags.
The forum is gaving me this error when I try to post code inside tags:
Code: newbielink:javascript:void(0); [nonactive]
and this
Sorry, you are not allowed to post external links.
----
Thank you all in advance!
Best Regards
Renato