View Single Post
  #3 (permalink)  
Old 8th June 2009, 11:33
goitalia goitalia is offline
D4PHP Enthusiast
 
Join Date: Apr 2007
Location: Milano
Posts: 182
goitalia is on a distinguished road
Default Find the solution

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('"','&quot;',$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
__________________
La guerre est un massacre entre gens qui ne se connaissent pas, et qu'il profite à des gens qui se connaissent mais qui ne se massacrent pas
Paul Valery
Reply With Quote
Sponsored Links