Skip to content

Instantly share code, notes, and snippets.

@devalexandre
Created October 18, 2015 18:53
Show Gist options
  • Save devalexandre/fb84a407c534c3427646 to your computer and use it in GitHub Desktop.
Save devalexandre/fb84a407c534c3427646 to your computer and use it in GitHub Desktop.
function onEdit($param)
{
try
{
if (isset($param['key']))
{
$key=$param['key']; // get the parameter $key
TTransaction::open('sample'); // open a transaction
$object = new Clientes($key); // instantiates the Active Record
$obj = new stdClass();
$obj->id = $object->id;
$obj->nome = $object->nome;
//array de telefones vazio
$telefones = array();
//pega os telefones
foreach($object->gettelefones() as $t):
coloca o telefone no array
$telefones[] = $t->id;
endforeach;
// aqui que da o pau
// não coloca os telefones no multfield
$obj->telefone = $telefones;
$this->form->setData($obj); // fill the form
TTransaction::close(); // close the transaction
}
else
{
$this->form->clear();
}
}
catch (Exception $e) // in case of exception
{
new TMessage('error', '<b>Error</b> ' . $e->getMessage()); // shows the exception error message
TTransaction::rollback(); // undo all pending operations
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment