im have a custom Extension, works fine, but dont change the data
My Code
public function PopulateData($entry,$values)
{
$entry->setProperty("my_custom_field_name", 'This is My Custom Field Content');
$values["my_custom_field_name"]='This is My Custom Field Content';
}
Entry Is Saved, without Changes
OK, real world Working Example in 2019
<?php
class Tcdcl_cart_ext
{
public function __construct()
{
$this->version = ee('Addon')->get('tcdcl_cart')->getVersion();
}
/**
* Activate extension, need this to register Hook, you can unninstall and install and hoock is activated and working
*/
public function activate_extension()
{
$hooks = array(
'before_channel_entry_save' => 'PopulateData',
);
foreach ($hooks as $hook => $method)
{
ee('Model')->make('Extension', [
'class' => __CLASS__,
'method' => $method,
'hook' => $hook,
'settings' => [],
'version' => $this->version,
'enabled' => 'y'
])->save();
}
}
public function PopulateData($entry,$values)
{
$entry->set(array("title"=>"Entry Custom Title, replace Form Filled title"));
}
/**
* Disable extension
*/
function disable_extension()
{
ee('Model')->get('Extension')
->filter('class', __CLASS__)
->delete();
}
/**
* Update extension
*/
function update_extension($current = '')
{
if ($current == '' OR $current == $this->version)
{
return FALSE;
}
}
}
// EOF
Those events don’t return anything, or let you modify the object. If you want to make changes to it, you have to call save()
$entry
->set(array("title"=>"Entry Custom Title, replace Form Filled title"))
->save();
But be careful b/c that may just end up calling before_channel_entry_save
again and creating a loop.
Thanks, for now im try writing custom Grid on FrontEnd(only Show Cart data, and hidden GRid Fields), and then compare if the form data, are the same in the “Cart” data.
Im have a Custom Cart, with Product ID, price, Quantity, total Price for each row, Channel “Quotation” have a Grid This grid Have related Field to Products Channel and integer fields -> price, Quantity, total Price
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.