From 606d7d718510428fbe3c467c326bab017ea53423 Mon Sep 17 00:00:00 2001 From: Zach Copley Date: Sun, 17 Apr 2011 14:29:38 -0700 Subject: [PATCH] Allow setting separate name and id on form input elements --- lib/htmloutputter.php | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/htmloutputter.php b/lib/htmloutputter.php index fdb693f92c..dac3c621fc 100644 --- a/lib/htmloutputter.php +++ b/lib/htmloutputter.php @@ -170,20 +170,21 @@ class HTMLOutputter extends XMLOutputter * @param string $label text of label for the element * @param string $value value of the element, default null * @param string $instructions instructions for valid input + * @param string $name name of the element; if null, the id will + * be used * - * @todo add a $name parameter * @todo add a $maxLength parameter * @todo add a $size parameter * * @return void */ - function input($id, $label, $value=null, $instructions=null) + function input($id, $label, $value=null, $instructions=null, $name=null) { $this->element('label', array('for' => $id), $label); - $attrs = array('name' => $id, - 'type' => 'text', - 'id' => $id); + $attrs = array('type' => 'text', + 'id' => $id); + $attrs['name'] = is_null($name) ? $id : $name; if (!is_null($value)) { // value can be 0 or '' $attrs['value'] = $value; } -- 2.39.2