Revision: 1503
http://mrbs.svn.sourceforge.net/mrbs/?rev=1503&view=rev
Author: cimorrison
Date: 2010-10-15 10:21:44 +0000 (Fri, 15 Oct 2010)
Log Message:
-----------
Added an optional $disabled parameter to the form input generating functions
Modified Paths:
--------------
mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
mrbs/branches/provisional_bookings_new_style/web/edit_users.php
mrbs/branches/provisional_bookings_new_style/web/functions.inc
Modified: mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
2010-10-15 09:57:31 UTC (rev 1502)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_entry.php
2010-10-15 10:21:44 UTC (rev 1503)
@@ -559,7 +559,7 @@
}
else
{
- generate_input($label_text, 'name', $name, $maxlength['entry.name']);
+ generate_input($label_text, 'name', $name, FALSE,
$maxlength['entry.name']);
}
echo "</div>\n";
Modified: mrbs/branches/provisional_bookings_new_style/web/edit_users.php
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/edit_users.php
2010-10-15 09:57:31 UTC (rev 1502)
+++ mrbs/branches/provisional_bookings_new_style/web/edit_users.php
2010-10-15 10:21:44 UTC (rev 1503)
@@ -419,7 +419,7 @@
}
break;
case 'email':
- generate_input($label_text, $var_name, $data[$key],
isset($maxlength["users.$key"]) ? $maxlength["users.$key"] : NULL);
+ generate_input($label_text, $var_name, $data[$key], FALSE,
isset($maxlength["users.$key"]) ? $maxlength["users.$key"] : NULL);
break;
default:
// Output a checkbox if it's a boolean or integer <= 2
bytes (which we will
@@ -447,7 +447,7 @@
// Otherwise output a text input
else
{
- generate_input($label_text, $var_name, $data[$key],
isset($maxlength["users.$key"]) ? $maxlength["users.$key"] : NULL);
+ generate_input($label_text, $var_name, $data[$key],
FALSE, isset($maxlength["users.$key"]) ? $maxlength["users.$key"] : NULL);
}
break;
} // end switch
Modified: mrbs/branches/provisional_bookings_new_style/web/functions.inc
===================================================================
--- mrbs/branches/provisional_bookings_new_style/web/functions.inc
2010-10-15 09:57:31 UTC (rev 1502)
+++ mrbs/branches/provisional_bookings_new_style/web/functions.inc
2010-10-15 10:21:44 UTC (rev 1503)
@@ -298,28 +298,38 @@
// Generate an input field with an associated label
-// Optional fourth parameter: $maxlength - the maximum length of input allowed
-function generate_input($label_text, $name, $value)
+// Optional fifth parameter: $maxlength - the maximum length of input allowed
+function generate_input($label_text, $name, $value, $disabled=FALSE)
{
- // get any optional fourth parameter
- if (func_num_args() > 3)
+ // get any optional fifth parameter
+ if (func_num_args() > 4)
{
- $maxlength = func_get_arg(3);
+ $maxlength = func_get_arg(4);
}
// generate the HTML
$html = "<label for=\"$name\">$label_text</label>\n";
$html .= "<input id=\"$name\" name=\"$name\" type=\"text\"";
+ $html .= ($disabled) ? " disabled=\"disabled\"" : '';
$html .= (isset($maxlength)) ? " maxlength=\"$maxlength\"" : '';
$html .= " value=\"" . htmlspecialchars($value) . "\">\n";
+ // and a hidden input if the input box is disabled
+ if ($disabled)
+ {
+ $html .= "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
+ }
echo $html;
}
// Generates a select box from $options, an array of options
-function generate_select($label_text, $name, $value, $options)
+// If $disabled is TRUE, then the select box is disabled and a hidden
+// input is generated to pass through $value
+function generate_select($label_text, $name, $value, $options, $disabled=FALSE)
{
// generate the HTML
$html = "<label for=\"$name\">$label_text</label>\n";
- $html .= "<select id=\"$name\" name=\"$name\">\n";
+ $html .= "<select id=\"$name\" name=\"$name\"";
+ $html .= ($disabled) ? " disabled=\"disabled\"" : '';
+ $html .= ">\n";
foreach ($options as $option)
{
$html .= "<option";
@@ -327,16 +337,31 @@
$html .= ">$option</option>\n";
}
$html .= "</select>\n";
+ // and a hidden input if the select box is disabled
+ if ($disabled)
+ {
+ $html .= "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
+ }
+
echo $html;
}
// Generate a textarea with an associated label
-function generate_textarea($label_text, $name, $value)
+// If $disabled is TRUE, then the textarea is disabled and a hidden
+// input is generated to pass through $value
+function generate_textarea($label_text, $name, $value, $disabled=FALSE)
{
// generate the HTML
$html = "<label for=\"$name\">$label_text</label>\n";
// textarea rows and cols are overridden by CSS height and width
- $html .= "<textarea id=\"$name\" name=\"$name\" rows=\"8\" cols=\"40\">" .
htmlspecialchars($value) . "</textarea>\n";
+ $html .= "<textarea id=\"$name\" name=\"$name\" rows=\"8\" cols=\"40\"";
+ $html .= ($disabled) ? " disabled=\"disabled\"" : '';
+ $html .= ">" . htmlspecialchars($value) . "</textarea>\n";
+ // and a hidden input if the textarea is disabled
+ if ($disabled)
+ {
+ $html .= "<input type=\"hidden\" name=\"$name\" value=\"$value\">\n";
+ }
echo $html;
}
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Download new Adobe(R) Flash(R) Builder(TM) 4
The new Adobe(R) Flex(R) 4 and Flash(R) Builder(TM) 4 (formerly
Flex(R) Builder(TM)) enable the development of rich applications that run
across multiple browsers and platforms. Download your free trials today!
http://p.sf.net/sfu/adobe-dev2dev
_______________________________________________
Mrbs-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mrbs-commits