protected function Form_Create() { // For now, let's load Person of ID #1 // Remember that $this is the Meta Control's parent, because every QControl // we get from PersonMetaControl should have $this form as its parent. $this->mctPerson = PersonMetaControl::Create($this, 1); // Instead of manually defining and setting up each QLabel and QTextBox, // we utilize MetaControl's _create() functionality to create them // for us. $this->lblFirstName = $this->mctPerson->lblFirstName_Create(); $this->lblLastName = $this->mctPerson->lblLastName_Create(); $this->txtFirstName = $this->mctPerson->txtFirstName_Create(); $this->txtLastName = $this->mctPerson->txtLastName_Create(); // Now, we customize these controls as we normally would // In this particular case, upon intial load, we want to see the Labels, but // we want the textboxes to be invisible $this->txtFirstName->Visible = false; $this->txtLastName->Visible = false; // Add a Pointer Cursor to the labels $this->lblFirstName->Cursor = QCursor::Pointer; $this->lblLastName->Cursor = QCursor::Pointer; // We can of course also define any additional controls we wish $this->btnSave = new QButton($this); $this->btnSave->Text = 'Save'; $this->btnSave->Visible = false; $this->btnCancel = new QButton($this); $this->btnCancel->Text = 'Cancel'; $this->btnCancel->Visible = false; // Finally, we can define all of our actions // ON some of these, we can override and set a CausesValidation handler $this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click', 'default', true)); $this->btnCancel->AddAction(new QClickEvent(), new QAjaxAction('btnCancel_Click')); $this->lblFirstName->AddAction(new QClickEvent(), new QAjaxAction('lblFirstName_Click')); $this->lblLastName->AddAction(new QClickEvent(), new QAjaxAction('lblLastName_Click')); $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click', 'default', true)); $this->txtFirstName->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtFirstName->AddAction(new QEscapeKeyEvent(), new QAjaxAction('btnCancel_Click', 'default', true)); $this->txtFirstName->AddAction(new QEscapeKeyEvent(), new QTerminateAction()); $this->txtLastName->AddAction(new QEnterKeyEvent(), new QAjaxAction('btnSave_Click', 'default', true)); $this->txtLastName->AddAction(new QEnterKeyEvent(), new QTerminateAction()); $this->txtLastName->AddAction(new QEscapeKeyEvent(), new QAjaxAction('btnCancel_Click', 'default', true)); $this->txtLastName->AddAction(new QEscapeKeyEvent(), new QTerminateAction()); }
/** * Static Helper Method to Create using QueryString arguments * * @param mixed $objParentObject QForm or QPanel which will be using this PersonMetaControl * @param QMetaControlCreateType $intCreateType rules governing Person object creation - defaults to CreateOrEdit * @return PersonMetaControl */ public static function CreateFromQueryString($objParentObject, $intCreateType = QMetaControlCreateType::CreateOrEdit) { $intId = QApplication::QueryString('intId'); return PersonMetaControl::Create($objParentObject, $intId, $intCreateType); }