hi,
first add a new component like that:
this is the package pp_edit
Quote:
<?php
require_once("vcl/vcl.inc.php");
use_unit("designide.inc.php");
setPackageTitle("Edit with record_id");
//Change this setting to the path where the icons for the components reside
setIconPath("./icons");
//Change yourunit.inc.php to the php file which contains the component code
registerComponents("Paolo_component",array("pp_edi t"),"/Paolo_components/pp_edit.inc.php");
?>
|
second built the new edit component with a property record_id
Quote:
<?php
require_once("vcl/vcl.inc.php");
//Includes
use_unit("stdctrls.inc.php");
//Class definition
class pp_edit extends Edit
{
protected $_record_id=-1;
function getrecord_id() { return $this->_record_id; }
function setrecord_id($value) { $this->_record_id=$value; }
function defaultrecord_id() { return -1; }
protected $_table_name='table_name';
function gettable_name() { return $this->_table_name; }
function settable_name($value) { $this->_table_name=$value; }
function defaulttable_name() { return 'table_name'; }
function __construct($aowner = null)
{
parent::__construct($aowner);
}
function dumpContents()
{
// set type depending on $_ispassword
$type = ($this->_ispassword) ? 'password' : 'text';
$attributes = $this->getCommonAttributes();
$style = $this->getCommonStyles();
if ($this->readHidden())
{
if (($this->ControlState & csDesigning) != csDesigning)
{
$style.=" visibility:hidden; ";
}
}
if ($style != "") $style = "style=\"$style\"";
if (($this->ControlState & csDesigning) != csDesigning)
{
if ($this->hasValidDataField())
{
//The value to show on the field is the one from the table
$this->_text = $this->readDataFieldValue();
//Dumps hidden fields to know which is the record to update
$this->dumpHiddenKeyFields();
}
}
// call the OnShow event if assigned so the Text property can be changed
if ($this->_onshow != null)
{
$this->callEvent('onshow', array());
}
$avalue=$this->_text;
$avalue=str_replace('"','"',$avalue);
echo "<input type=\"$type\" id=\"$this->_name\" onchange=\"return {$this->Name}_updatehidden(event)\" name=\"$this->_name\" record_id=$this->_record_id field_name=$this->_datafield table_name=$this->_table_name value=\"$avalue\" $style $attributes />";
}
}
?>
|
in the DbRepeater on show event
Quote:
|
$this->pp_edit1->record_id = $this->table->fieldget('record_id');
|
and in the js event on change
Quote:
var target = event.target || event.srcElement;
alert ('input text '+ target.value);
alert ('record_id='+target.getAttribute('record_id'));
return false;
|
That' all folks.

Paolo