Home » HTML » HTML_Template_IT » Bug #7460
PHP notice
Details
| Submitted | 2006-04-23 08:32 UTC |
|---|---|
| From | mvonarx at tiscali dot ch |
| Assigned | dsp |
| Status | Bogus |
| Package | HTML_Template_IT |
| PHP Version | Irrelevant |
| OS | not relevant |
| Roadmaps | (Not assigned) |
Comments
[2006-04-23 08:32 UTC] mvonarx at tiscali dot ch
Description:
------------
If you are defining $formname_error_block or $formname_required_block in your Template you get PHP Notices.
Env:
HTML_Template_IT v1.1.4
HTML_QuickForm v3.2.4
Btw, If you are using HTML_Template_Sigma (in my code example) instead, you do not get the PHP notice.
Test script:
---------------
/**
* generating the notice
*/
$oForm = new HTML_QuickForm('form','post',$_SERVER['PHP_SELF']);
$tpl =& new HTML_Template_ITX('./template');
$tpl->loadTemplateFile('_form.html');
$renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
$oForm->accept($renderer);
return $tpl->get();
/**
* solution could be
* maybe recoding this section could be a solution too
*/
if ( isset($this->blockdata[$innerblock])
&& ($this->blockdata[$innerblock] != ''))
{
$empty = false;
} else {
//setting it
$this->blockdata[$innerblock] = "";
}
Expected result:
----------------
No PHP Notice
Actual result:
--------------
Notice: Undefined index: form_error_block in d:\xampp\php\pear\HTML\Template\IT.php on line 544
Notice: Undefined index: form_error_block in d:\xampp\php\pear\HTML\Template\IT.php on line 552
Notice: Undefined index: form_required_block in d:\xampp\php\pear\HTML\Template\IT.php on line 544
Notice: Undefined index: form_required_block in d:\xampp\php\pear\HTML\Template\IT.php on line 552
[2006-04-23 14:17 UTC] mvonarx at tiscali dot ch
/**
* Following demonstrates the behavior
*
* it only occurs when customizing required_block and/or
* error_block inside template
*
* template/_form.html
* looks like this...
*/
/*
<!-- BEGIN form_error_loop -->
<font color="red">{form_error}</font><br />
<!-- END form_error_loop -->
<!-- BEGIN form_error_block -->
<font color="blue" size="1">{form_error}</font><br />
{form_html}
<!-- END form_error_block -->
<!-- BEGIN form_required_block -->
{form_label} <font color="green" size="1">*</font>
<!-- END form_required_block -->
<!-- BEGIN PAGE_FORM -->
<form {form_attributes}>
<table border="0" cellspacing="0" cellpadding="0">
<tr>
<td>{form_name_label}</td>
<td>{form_name_html}</td>
</tr>
<tr>
<td colspan="2">{form_required_note}</td>
</tr>
<tr>
<td colspan="2">
{form_btnsave_html}
</td>
</tr>
</table>
</form>
<!-- END PAGE_FORM -->
*/
require_once "HTML/QuickForm.php";
require_once "HTML/QuickForm/Renderer/ITStatic.php";
require_once "HTML/Template/ITX.php";
require_once "HTML/Template/Sigma.php";
//generate a very simple form
$oForm = new HTML_QuickForm('form','post',$_SERVER['PHP_SELF']);
$oForm->addElement("text","name","name: ");
$oForm->addElement("submit","btnsave","save");
$oForm->addRule('name','input required','required',null,'server');
//using ITX Template causes the notice
$tpl =& new HTML_Template_ITX('./template');
//using Sigma Template causes no notice
//$tpl =& new HTML_Template_Sigma('./template');
$tpl->loadTemplateFile('_form.html');
$renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
$oForm->accept($renderer);
$tpl->show();
/**
Notice: Undefined index: form_required_block in d:\xampp\php\pear\HTML\Template\IT.php on line 544
Notice: Undefined index: form_required_block in d:\xampp\php\pear\HTML\Template\IT.php on line 552
*/
[2006-04-27 17:56 UTC] mvonarx at tiscali dot ch
the given example always prints a PHP Notice as statet at the end of the example. What is your error_reporting level?
after doing some tests i found out that it ONLY occurs if you use TemplateIt and ITStaticRenderer.
as i mentioned earlier it can not be reproduced with stantalone Template_IT. Maybe i missunderstood something in QuickForm. I assumed that i do not have to use the setErrorTemplate and/or setRequiredTemplate functions of the ITStatic Renderer if i define these blocks directly in my template file.
Because the Notice occured in IT.php i posted it here. maybe its a documentation problem of the QuickForm maintainers.
because Template_Sigma and its QuickForm renderer checks if critical array indexes are set before accessing them ther will never be a PHP Notice. I guess I take this renderer in future.
So please improve the sections as already mentioned.
[2006-12-03 19:16 UTC] dsp at php dot net
This is not a HTML_Template_IT issue and not reproduceable with a standalone HTML_Template_IT. Maybe it's a QuickForm problem, but ITStaticRenderer is not part of the HTML_Template_IT package, so it's bogus.