QPanel child(s) validation error message
Hi folks!
I have few a question about child controls inside a QPanel. For an example here is some code (I just extendend the provided sample.php):
<?php
// Include prepend.inc to load Qcodo
require('includes/configuration/prepend.inc.php');
class SampleForm extends QForm {
protected $lblMessage;
protected $btnButton;
protected $pnlControls;
protected $btnSave;
protected function Form_Create() {
$this->lblMessage = new QLabel($this);
$this->lblMessage->Text = 'Click the button to change my message.';
$this->btnButton = new QButton($this);
$this->btnButton->Text = 'Click Me';
$this->btnButton->AddAction(new QClickEvent(), new QServerAction('btnButton_Click'));
$this->btnSave = new QButton($this);
$this->btnSave->Text = 'save';
$this->btnSave->AddAction(new QClickEvent(), new QAjaxAction('btnSave_Click'));
$this->btnSave->CausesValidation = true;
$this->pnlControls = new QPanel($this);
$this->pnlControls->AutoRenderChildren = true;
for ($i=0; $i < 4; $i++) {
$label = new QLabel($this->pnlControls);
$txtBox = new QTextBox($this->pnlControls);
$txtBox->ActionParameter = $i;
$txtBox->ValidateTrimmed = true;
$txtBox->Required = true;
$txtBox->Name = 'Name'.$i;
$label->Text = "Field".$i;
}
}
protected function Form_Validate() {return true;}
protected function btnSave_Click() {
QApplication::DisplayAlert('save');
}
protected function btnButton_Click($strFormId, $strControlId, $strParameter) {
$this->lblMessage->Text = 'Hello, World!';
}
}
SampleForm::Run('SampleForm');
?>Template:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html><head>
<meta http-equiv="Content-Type" content="text/html; charset=<?php _p(QApplication::$EncodingType); ?>" />
<title>Sample QForm</title>
<style type="text/css">@import url("<?php _p(__VIRTUAL_DIRECTORY__ . __CSS_ASSETS__); ?>/styles.css");</style>
</head><body>
<?php $this->RenderBegin(); ?>
<p><?php $this->lblMessage->Render(); ?></p>
<p><?php $this->btnButton->Render(); ?></p>
<p><?php $this->pnlControls->RenderWithError(); ?></p>
<p><?php $this->btnSave->Render(); ?></p>
<?php $this->RenderEnd(); ?>
</body></html>So, it's basically dynamically creating QTextBox controls which are childs of a QPanel. As you see there are also a QLabel controls, which are used instead QTextBox->Name. Is possible to render QTextBox created like that (dynamically) to get a result as RenderWithName (to render controls' QTextBox->Name)?
Second question would be about validation error message. Validation goes through, if the QTextBox fields are empty the method btnSave_Click() isn't called, but there isn't any error message provided (field xyz is required).
