Merge branch 'MDL-30845-master' of git://github.com/ankitagarwal/moodle

This commit is contained in:
Aparup Banerjee 2012-10-15 14:21:11 +08:00
commit af6b7edaee
2 changed files with 27 additions and 15 deletions

View File

@ -64,6 +64,33 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{
$this->_hiddenLabel = $hiddenLabel;
}
/**
* Freeze the element so that only its value is returned and set persistantfreeze to false
*
* @since 2.4
* @access public
* @return void
*/
function freeze()
{
$this->_flagFrozen = true;
// No hidden element is needed refer MDL-30845
$this->setPersistantFreeze(false);
} //end func freeze
/**
* Returns the html to be used when the element is frozen
*
* @since 2.4
* @return string Frozen html
*/
function getFrozenHtml()
{
$attributes = array('readonly' => 'readonly');
$this->updateAttributes($attributes);
return $this->_getTabs() . '<input' . $this->_getAttrString($this->_attributes) . ' />' . $this->_getPersistantData();
} //end func getFrozenHtml
/**
* Returns HTML for this form element.
*
@ -88,18 +115,4 @@ class MoodleQuickForm_text extends HTML_QuickForm_text{
return $this->_helpbutton;
}
/**
* Slightly different container template when frozen. Don't want to use a label tag
* with a for attribute in that case for the element label but instead use a div.
* Templates are defined in renderer constructor.
*
* @return string
*/
function getElementTemplateType(){
if ($this->_flagFrozen){
return 'static';
} else {
return 'default';
}
}
}

View File

@ -160,7 +160,6 @@ class qtype_numerical_edit_form extends question_edit_form {
$firstunit = $mform->getElement('multiplier[0]');
$firstunit->freeze();
$firstunit->setValue('1.0');
$firstunit->setPersistantFreeze(true);
$mform->addHelpButton('multiplier[0]', 'numericalmultiplier', 'qtype_numerical');
}
}