Source for file DefaultWidget.php
Documentation is available at DefaultWidget.php
* This file was generated by the Alia Toolkit. For more information, please see alia.sourceforge.net
* A widget for manipulating a '.
CRUD_CLASS.
' object.
* The records primary key. This is used to repopulate the widget on wakeup
private $primaryKey=null;
* the AValidator object used for validation
* The actual doctrine record object that will be viewed/edited by this widget
function __construct($_record=null){
$this->defineSignal("saveSucess");
$this->defineSignal("saveFail",1);
$this->primaryKey=$_record->identifier();
//define our saveClicked signal
$this->defineSignal("saveClicked");
//instantiate the validator
$this->validator = new AValidator();
$this->setupConnections();
$this->validator->sendJScript();
* Magic method is executed whenever the object is unserialized.
//we have to re-fetch the record on wakeup because doctrine doesn\'t serialize relationships
$this->record = Doctrine::getTable("'.
CRUD_CLASS.
'")->find($this->primaryKey);
return array("validator","primaryKey");
* builds the layout and widgets that go in it.
$layout = new AHTMLLayout($this,"/templates/'.
CRUD_WIDGET.
'Edit.tpl");
$this->setLayout($layout);
foreach($columns as $column=>
$vals){
$buffer.=
"\n\n".
' //'.
"The '$column' widget";
$buffer.=
"\n".
' $widget=new ALineEdit($this->record->'.
$column.
');';
$buffer.=
"\n".
' $widget->setAttribute("maxlength",'.
$vals['length'].
');';
$buffer.=
"\n".
' $widget->addAttribute("name")->setAttribute("name","'.
$column.
'");';
$buffer.=
"\n".
' $layout->addWidget($widget, "'.
$column.
'");';
$buffer.=
"\n".
' $this->validator->add($x++,"int",null,$widget->getAttribute("id"));';
$buffer.=
"\n".
' $widget=new ALineEdit($this->record->'.
$column.
');';
$buffer.=
"\n".
' $widget->setAttribute("maxlength",'.
$vals['length'].
');';
$buffer.=
"\n".
' $widget->addAttribute("name")->setAttribute("name","'.
$column.
'");';
$buffer.=
"\n".
' $layout->addWidget($widget, "'.
$column.
'");';
$buffer.=
"\n".
' $this->validator->add($x++,"string",array("maxLength"=>'.
$vals['length'].
'), $widget->getAttribute("id"));';
$buffer.=
"\n\n".
' $layout->addWidget(new ALineEdit($this->record->'.
$column.
'), "'.
$column.
'");';
$saveButton = new APushButton("Save");
$layout->addWidget($saveButton,"_saveButton");
* sets up the signal and default connection for saving the form.
function setupConnections(){
$button=$this->getLayout()->getWidget("_saveButton");
//emit a saveClicked signal when the user hits save. The signal passes all form information to all slots.
Alia::connect($button,"clicked", null, null, "" . AJScript::emit("saveClicked",$this,array(';
foreach($columns as $column=>
$vals){
$buffer.=
"\n\t\t\t".
'AJScript::formElementValue($this->getLayout()->getWidget("'.
$column.
'"))';
//connect the save() method to the saveClicked signal
Alia::connect($this,"saveClicked",$this,"save");
* Saves the record to the database
* Called when the user hits save button by default.
foreach($columns as $column=>
$vals){
$result=$this->validator->validate($args);
$this->emit("saveFail", $result);
foreach($columns as $column=>
$vals){
$buffer.=
"\n".
' $this->record->'.
$column.
'=(int)$'.
$column.
';';
$buffer.=
"\n".
' $this->record->'.
$column.
'=$'.
$column.
';';
$buffer.=
"\n".
' $this->primaryKey = $this->record->'.
$key.
';'.
"\n";
$buffer.=
' $this->emit("saveSuccess");
Documentation generated on Fri, 11 Jul 2008 13:28:45 -0400 by phpDocumentor 1.4.2