Fix rendering of js_calendar on add_attr, when no previous DateAttributes existed

This commit is contained in:
Deon George 2009-09-20 11:21:59 +10:00
parent 9196bb9e41
commit a6dc80616b
2 changed files with 10 additions and 17 deletions

View File

@ -160,6 +160,7 @@ if (get_request('meth','REQUEST') != 'ajax') {
echo '<table class="entry" cellspacing="0" align="center" border=0>'; echo '<table class="entry" cellspacing="0" align="center" border=0>';
$request['page']->draw('Template',$attribute); $request['page']->draw('Template',$attribute);
$request['page']->draw('Javascript',$attribute);
echo '</table>'; echo '</table>';
} else { } else {

View File

@ -1598,23 +1598,15 @@ function validateForm(silence) {
$this->drawTemplateJavascript(); $this->drawTemplateJavascript();
# If we have a DateAttribute, we need to set some defaults for the js_calendar. # For DateAttributes, we need to set some defaults for the js_calendar.
if (isset($_SESSION[APPCONFIG])) { echo '<!-- START: GLOBAL SETTINGS FOR THE js_calendar -->'."\n";
foreach ($this->template->getAttributesShown() as $attribute) { echo '<script type="text/javascript" language="javascript">'."\n";
if (array_key_exists($attribute->getName(),array_change_key_case($_SESSION[APPCONFIG]->getValue('appearance','date_attrs')))) { echo 'var defaults = new Array();'."\n";
echo '<!-- START: GLOBAL SETTINGS FOR THE js_calendar -->'."\n"; printf('var default_date_format = "%s";',$_SESSION[APPCONFIG]->getValue('appearance','date'));
echo '<script type="text/javascript" language="javascript">'."\n"; echo "\n";
echo 'var defaults = new Array();'."\n"; echo '</script>'."\n";
printf('var default_date_format = "%s";',$_SESSION[APPCONFIG]->getValue('appearance','date')); echo '<!-- END: GLOBAL SETTINGS FOR THE js_calendar -->'."\n";
echo "\n"; echo "\n";
echo '</script>'."\n";
echo '<!-- END: GLOBAL SETTINGS FOR THE js_calendar -->'."\n";
echo "\n";
break;
}
}
}
foreach ($this->template->getAttributesShown() as $attribute) foreach ($this->template->getAttributesShown() as $attribute)
$this->draw('Javascript',$attribute); $this->draw('Javascript',$attribute);