Hi all,
I found out by updating CC to version 5 that there are different column names in create table.
old version did use column like cf_created and cf_modifiet with datestamp, but it doesnt update the values (dates) after modification of the record in table that were created in CCv4.
where is the problem?
thx
I found out by updating CC to version 5 that there are different column names in create table.
old version did use column like cf_created and cf_modifiet with datestamp, but it doesnt update the values (dates) after modification of the record in table that were created in CCv4.
where is the problem?
thx
Hi homeopat,
I saw something similar today with the IP address. It looks as though Max hasn't added the code to automatically generate those entries in CFv5 :-(
You can probably do it with a custom code action something like this:
Bob
I saw something similar today with the IP address. It looks as though Max hasn't added the code to automatically generate those entries in CFv5 :-(
You can probably do it with a custom code action something like this:
<?php
$user = JFactory::getUser();
if ( isset($form->data['cf_id']) && $form->data['cf_id'] > 0 ) {
// this is a modification
$form->data['cf_modified'] = date('Y-m-d H:i:s');;
$form->data['cf_modified_by'] = $user->id;
} else {
// this is a new record
$form->data['cf_created'] = date('Y-m-d H:i:s');;
$form->data['cf_created_by'] = $user->id;
}
?>
Bob
Hi Bob,
thx for code, it works, but partially.
in main model it works fine, when update then cf_modified is updated.
but there is a problem in second and next models (models: oteviracky, pronajimatel). When I update informations in model oteviracky then datetime is updated in cf_created but not in cf_modified.
the scheme of relations is (I use models id):
any idea?
thx for code, it works, but partially.
in main model it works fine, when update then cf_modified is updated.
but there is a problem in second and next models (models: oteviracky, pronajimatel). When I update informations in model oteviracky then datetime is updated in cf_created but not in cf_modified.
<?php
$user = JFactory::getUser();
if ( isset($form->data['zakladni']['cf_id']) && $form->data['zakladni']['cf_id'] > 0 )
{
// this is a modification
$form->data['zakladni']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['zakladni']['cf_modified_by'] = $user->id;
}
else
{
// this is a new record
$form->data['zakladni']['cf_created'] = date('Y-m-d H:i:s');
$form->data['zakladni']['cf_created_by'] = $user->id;
}
if ( isset($form->data['oteviracky']['cf_id']) && $form->data['oteviracky']['cf_id'] > 0 )
{
// this is a modification
$form->data['oteviracky']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['oteviracky']['cf_modified_by'] = $user->id;
}
else
{
// this is a new record
$form->data['oteviracky']['cf_created'] = date('Y-m-d H:i:s');
$form->data['oteviracky']['cf_created_by'] = $user->id;
}
if ( isset($form->data['pronajimatel']['cf_id']) && $form->data['pronajimatel']['cf_id'] > 0 )
{
// this is a modification
$form->data['pronajimatel']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['pronajimatel']['cf_modified_by'] = $user->id;
}
else
{
// this is a new record
$form->data['pronajimatel']['cf_created'] = date('Y-m-d H:i:s');
$form->data['pronajimatel']['cf_created_by'] = $user->id;
}
if ( isset($form->data['pronajimatelkontakty']['cf_id']) && $form->data['pronajimatelkontakty']['cf_id'] > 0 )
{
// this is a modification
$form->data['pronajimatelkontakty']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['pronajimatelkontakty']['cf_modified_by'] = $user->id;
}
else
{
// this is a new record
$form->data['pronajimatelkontakty']['cf_created'] = date('Y-m-d H:i:s');
$form->data['pronajimatelkontakty']['cf_created_by'] = $user->id;
}
?>
the scheme of relations is (I use models id):
1st (main) -> 2nd (has realation HasOne)
1st (main) -> 3rd (has realation HasOne)
3rd -> 4th (has realation HasToMany)
any idea?
Hi Homeopat,
Hard to say, You'd need to add a Debugger action and check what variables give you the information you need to decide if the record already exists or not.
Bob
Hard to say, You'd need to add a Debugger action and check what variables give you the information you need to decide if the record already exists or not.
Bob
Hi Bob, data are read .. cf_uid issset and > 0, but condition decide that cf_uid is not set or <0
I dont understand why
[oteviracky] => Array
(
[cf_id] => 1
[cf_uid] => 449730604086591
[cf_created] => 2014-06-11 08:57:31
[cf_modified] => 2013-10-02 07:46:26
[cf_created_by] => 538
[cf_modified_by] => 538
[cf_ipaddress] => 192.168.2.131
[cf_user_id] => 536
[po_pa] => 08:00 - 18:04
[so] => 08:30 - 12:31
[ne] => -
[poledni_prestavka] =>
)
I dont understand why
Hi homeopat,
I don't see why both sets of records are being set :-( I can only suggest that you add some debug code to work out exactly what is happening at each step.
Bob
I don't see why both sets of records are being set :-( I can only suggest that you add some debug code to work out exactly what is happening at each step.
Bob
I am not sure if u understand me. I am saying that datetime is updated is second and further tables to cf_created instead of cr_modified. it is udpated correctly In main table.
Hi homepat,
Yes, that's what I understood, I just haven't worked out why that is happening :-(
Bob
Yes, that's what I understood, I just haven't worked out why that is happening :-(
Bob
It is interesting, same code works different🙂
I tried modify the code to simple condition and works it
but partially. model pronajimatel hasMany of pronajimatelkontakty and an update doesnt work in this case. I mean.... 1 record of pronajimatel can have 11 records of pronajimatelkontakty.
thx
<?php
$user = JFactory::getUser();
if ( isset($form->data['zakladni']['cf_id']) && $form->data['zakladni']['cf_id'] > 0 )
{
// this is a modification
$form->data['zakladni']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['zakladni']['cf_modified_by'] = $user->id;
$form->data['oteviracky']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['oteviracky']['cf_modified_by'] = $user->id;
$form->data['pronajimatel']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['pronajimatel']['cf_modified_by'] = $user->id;
$form->data['pronajimatelkontakty']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['pronajimatelkontakty']['cf_modified_by'] = $user->id;
$form->data['him']['cf_modified'] = date('Y-m-d H:i:s');
$form->data['him']['cf_modified_by'] = $user->id;
}
else
{
// this is a new record
$form->data['zakladni']['cf_created'] = date('Y-m-d H:i:s');
$form->data['zakladni']['cf_created_by'] = $user->id;
$form->data['oteviracky']['cf_created'] = date('Y-m-d H:i:s');
$form->data['oteviracky']['cf_created_by'] = $user->id;
$form->data['pronajimatel']['cf_created'] = date('Y-m-d H:i:s');
$form->data['pronajimatel']['cf_created_by'] = $user->id;
$form->data['pronajimatelkontakty']['cf_created'] = date('Y-m-d H:i:s');
$form->data['pronajimatelkontakty']['cf_created_by'] = $user->id;
$form->data['him']['cf_created'] = date('Y-m-d H:i:s');
$form->data['him']['cf_created_by'] = $user->id;
}
?>
but partially. model pronajimatel hasMany of pronajimatelkontakty and an update doesnt work in this case. I mean.... 1 record of pronajimatel can have 11 records of pronajimatelkontakty.
thx
Hi,
v5 will update columns named "created" and "modified" instead, so please rename your 2 columns and it should work fine automatically!
You may have to click the "clear cache" button in the Connectivity admin home page to clear the tables fields cache!
Regards,
Max
v5 will update columns named "created" and "modified" instead, so please rename your 2 columns and it should work fine automatically!
You may have to click the "clear cache" button in the Connectivity admin home page to clear the tables fields cache!
Regards,
Max
This topic is locked and no more replies can be posted.