Active
Project:
PHPTemplate
Version:
4.6.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
27 Dec 2005 at 21:20 UTC
Updated:
27 Dec 2005 at 21:20 UTC
This doesn't seem like it should fail, but it does.
Using Drupal 4.6.3 on PHP 4.3.9 PHPTemplate 1.24.2.4
Added file to themes dir: template.php
<?php
function phptemplate_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
// will be assigned within your template.
return _phptemplate_callback('form_element', array('title' => $title, 'value' => $value, 'description' => $description, 'id' => $id, 'required' => $required, 'error' => $error));
}
?>
Added form_elememt.tpl.php to themes directory:
<?php
$output ="";
$output = "<div class=\"form-item\">\n";
$required = $required ? '<span class="form-required">*</span>' : '';
if ($title) {
if ($id) {
$output .= "<div class=\"label\"><label for=\"$id\">$title:</label>$required</div>\n";
}
else {
$output .= "<div class=\"label\"><label>$title:</label>$required</div>\n";
}
}
$output .= "<div class=\"value\">$value</div>\n";
if ($description) {
$output .= "<div class=\"description\">$description</div>\n";
}
$output .= "</div>\n";
print $output;
?>
Works just great for form display (which was my intent).
But it breaks the site when submitting any form. Now, this is possibly not a PHPTemplate bug, but when I insert the following:
<?php
/**
* Create an form_element function, and redirect through the template api
**/
print "hello";
function phptemplate_form_element($title, $value, $description = NULL, $id = NULL, $required = FALSE, $error = FALSE) {
// Pass to phptemplate, including translating the parameters to an associative array. The element names are the names that the variables
// will be assigned within your template.
return _phptemplate_callback('form_element', array('title' => $title, 'value' => $value, 'description' => $description, 'id' => $id, 'required' => $required, 'error' => $error));
}
?>
And then submit a form, I get "hello" and then a page crash (blank white PHP blankness).
Oddly, the form does submit and process correctly AFAIK. It just looks like the redirect function gets broken. If I remove the template.php file, this problem goes away.
Maybe I'm dropping a variable somewhere.