[Pieforms-commit] SF.net SVN: pieforms: [138] pieforms-php5/trunk/src/pieform/elements/expiry .php
Status: Alpha
Brought to you by:
oracleshinoda
|
From: <ora...@us...> - 2006-12-24 00:22:21
|
Revision: 138
http://svn.sourceforge.net/pieforms/?rev=138&view=rev
Author: oracleshinoda
Date: 2006-12-23 16:20:47 -0800 (Sat, 23 Dec 2006)
Log Message:
-----------
Updated the expiry element to work with the error javascript stuff.
Modified Paths:
--------------
pieforms-php5/trunk/src/pieform/elements/expiry.php
Modified: pieforms-php5/trunk/src/pieform/elements/expiry.php
===================================================================
--- pieforms-php5/trunk/src/pieform/elements/expiry.php 2006-12-24 00:19:12 UTC (rev 137)
+++ pieforms-php5/trunk/src/pieform/elements/expiry.php 2006-12-24 00:20:47 UTC (rev 138)
@@ -33,6 +33,7 @@
* @return string The HTML for the element
*/
function pieform_element_expiry(Pieform $form, $element) {
+ $formname = $form->get_name();
$result = '';
$name = $element['name'];
if (!isset($element['defaultvalue'])) {
@@ -46,9 +47,9 @@
$seconds = $element['value'];
$values = pieform_element_expiry_get_expiry_from_seconds($element['value']);
}
- else if (isset($global[$element['name'] . '_number'])
+ else if (isset($global[$element['name']])
&& isset($global[$element['name'] . '_units'])) {
- $values = array('number' => $global[$element['name'] . '_number'],
+ $values = array('number' => $global[$element['name']],
'units' => $global[$element['name'] . '_units']);
$seconds = $values['number'] * pieform_element_expiry_seconds_in($values['units']);
}
@@ -65,11 +66,12 @@
// Same with the select. And do the events using mochikit signal instead of dom events
$numberinput = '<input';
$numberinput .= ($values['units'] == 'noenddate' && empty($element['rules']['required'])) ? ' disabled="disabled"' : '';
- $numberinput .= ' type="text" size="4" name="' . $name . '_number"';
- $numberinput .= ' id="' . $name . '_number" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . "\">\n";
+ $numberinput .= ' type="text" size="4" name="' . $name . '"';
+ $numberinput .= ' id="' . $formname . '_' . $name . '" value="' . $values['number'] . '" tabindex="' . $element['tabindex'] . '"';
+ $numberinput .= (isset($element['error']) ? ' class="error"' : '') . ">\n";
$uselect = '<select onchange="' . $name . '_change()" ';
- $uselect .= 'name="' . $name . '_units" id="' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n";
+ $uselect .= 'name="' . $name . '_units" id="' . $formname . '_' . $name . '_units"' . ' tabindex="' . $element['tabindex'] . "\">\n";
foreach (pieform_element_expire_get_expiry_units() as $u) {
// Don't allow 'no end date' if the element is required
if ($u == 'noenddate' && !empty($element['rules']['required'])) {
@@ -85,11 +87,11 @@
$script = <<<EOJS
<script type="text/javascript" language="javascript">
function {$name}_change() {
- if ($('{$name}_units').value == 'noenddate') {
- $('{$name}_number').disabled = true;
+ if ($('{$formname}_{$name}_units').value == 'noenddate') {
+ $('{$formname}_{$name}').disabled = true;
}
else {
- $('{$name}_number').disabled = false;
+ $('{$formname}_{$name}').disabled = false;
}
}
</script>
@@ -113,7 +115,7 @@
return null;
}
$allunits = pieform_element_expire_get_expiry_units();
- $number = $global[$name . '_number'];
+ $number = $global[$name];
if (!in_array($unit,$allunits) || $number < 0) {
return null;
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|