From: Zach Copley Date: Sun, 17 Apr 2011 21:29:38 +0000 (-0700) Subject: Allow setting separate name and id on form input elements X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=606d7d718510428fbe3c467c326bab017ea53423;p=quix0rs-gnu-social.git Allow setting separate name and id on form input elements --- 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; }