Removed autolink support from radio button field (not needed).
Fixed bug for empty muti menu and multi checkbox fields. Added "Choose..." as first item in single selection menu. Added relevant string in en language. Updated /mod/data/lib.php, function store_data_content() so that we store empty content for fields too.
This commit is contained in:
+1
-1
@@ -133,7 +133,7 @@
|
||||
********************************************/
|
||||
$entrysaved = false; //flag for displaying entry saved msg
|
||||
|
||||
if ($datarecord = data_submitted() and confirm_sesskey()) {
|
||||
if ($datarecord = data_submitted() and confirm_sesskey()) {
|
||||
//if rid is present, we are in updating mode
|
||||
if ($rid){
|
||||
foreach ($datarecord as $name=>$value){
|
||||
|
||||
@@ -61,27 +61,26 @@ class data_field_checkbox extends data_field_base {
|
||||
notify('That is not a valid field id!');
|
||||
exit;
|
||||
}
|
||||
$content = array();
|
||||
|
||||
if ($rid) {
|
||||
$content = get_record('data_content', 'fieldid', $id, 'recordid', $rid);
|
||||
if (isset($content->content)) {
|
||||
$dbcontent = get_record('data_content', 'fieldid', $id, 'recordid', $rid);
|
||||
if (isset($dbcontent->content)) {
|
||||
$content = $content->content;
|
||||
$content = explode('##', $content);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$content = array();
|
||||
}
|
||||
$str = '';
|
||||
|
||||
if ($field->description) {
|
||||
$str .= '<img src="'.$CFG->pixpath.'/help.gif" alt="'.$field->description.'" title="'.$field->description.'" /> ';
|
||||
}
|
||||
|
||||
foreach (explode("\n",$field->param1) as $checkbox) {
|
||||
foreach (explode("\n", $field->param1) as $checkbox) {
|
||||
$checkbox = ltrim(rtrim($checkbox));
|
||||
$str .= '<input type="checkbox" name="field_' . $field->id . '[]" id="field_';
|
||||
$str .= $field->id . '[]" value="' . $checkbox . '" ';
|
||||
|
||||
|
||||
if (array_search($checkbox, $content) !== false) {
|
||||
// Selected by user.
|
||||
$str .= 'checked />';
|
||||
|
||||
@@ -70,10 +70,12 @@ class data_field_menu extends data_field_base {
|
||||
$str .= '<img src="'.$CFG->pixpath.'/help.gif" alt="'.$field->description.'" title="'.$field->description.'"> ';
|
||||
}
|
||||
$str .= get_string('menu','data').'</td><td>';
|
||||
|
||||
|
||||
$str .= '<SELECT name="field_'.$field->id.' id="field_'.$field->id.'>';
|
||||
foreach (explode("\n",$field->param1) as $option){
|
||||
if (trim($content) == trim($option)) { //if selected
|
||||
$str .= '<option value="">' . get_string('menuchoose', 'data') . '</option>';
|
||||
|
||||
foreach (explode("\n",$field->param1) as $option) {
|
||||
if (trim($content) == trim($option)) { // If selected
|
||||
$str.='<option value="'.ltrim(rtrim($option)).'" SELECTED>'.ltrim(rtrim($option)).'</option>';
|
||||
} else {
|
||||
$str.='<option value="'.ltrim(rtrim($option)).'">'.ltrim(rtrim($option)).'</option>';
|
||||
|
||||
@@ -61,16 +61,15 @@ class data_field_multimenu extends data_field_base {
|
||||
notify('That is not a valid field id!');
|
||||
exit;
|
||||
}
|
||||
$content = array();
|
||||
|
||||
if ($rid) {
|
||||
$content = get_record('data_content', 'fieldid', $id, 'recordid', $rid);
|
||||
if (isset($content->content)) {
|
||||
$content = $content->content;
|
||||
$dbcontent = get_record('data_content', 'fieldid', $id, 'recordid', $rid);
|
||||
if (isset($dbcontent->content)) {
|
||||
$content = $dbcontent->content;
|
||||
$content = explode('##', $content);
|
||||
}
|
||||
}
|
||||
else {
|
||||
$content = array();
|
||||
}
|
||||
$str = '';
|
||||
|
||||
if ($field->description) {
|
||||
@@ -154,7 +153,7 @@ class data_field_multimenu extends data_field_base {
|
||||
|
||||
$field = get_record('data_fields', 'id', $fieldid);
|
||||
|
||||
if ($content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $recordid)) {
|
||||
if ($content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $recordid)){
|
||||
return $content->content;
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -229,7 +229,7 @@ class data_field_textarea extends data_field_base {
|
||||
*************************************/
|
||||
function update_data_content($fieldid, $recordid, $value, $name=''){
|
||||
// If data_content already exists, we update.
|
||||
if ($oldcontent = get_record('data_content','fieldid', $fieldid, 'recordid', $recordid)){
|
||||
if ($oldcontent = get_record('data_content', 'fieldid', $fieldid, 'recordid', $recordid)){
|
||||
$content = new object;
|
||||
$content->fieldid = $fieldid;
|
||||
$content->recordid = $recordid;
|
||||
|
||||
@@ -17,6 +17,7 @@ $string['confirmdeletefield'] = 'You are about to delete this field, are you sur
|
||||
$string['confirmdeleterecord'] = 'Are you sure you want to delete this record?';
|
||||
$string['deletefield'] = 'Delete an existing Field';
|
||||
$string['menu'] = 'Menu (Single-selection)';
|
||||
$string['menuchoose'] = 'Choose...';
|
||||
$string['emptyadd'] = 'The Add template is empty, generating a default form...';
|
||||
$string['emptyaddform'] = 'You did not fill out any fields!';
|
||||
$string['entrysaved'] = 'Entry Saved';
|
||||
|
||||
+10
-8
@@ -137,6 +137,11 @@ class data_field_base { //base class (text field)
|
||||
if ($content = get_record('data_content', 'fieldid', $fieldid, 'recordid', $recordid)){
|
||||
if (isset($content->content)){
|
||||
$str = format_text($content->content, $content->content1);
|
||||
|
||||
echo '<pre>';
|
||||
print_r($str);
|
||||
echo '</pre>';
|
||||
|
||||
} else {
|
||||
$str = '';
|
||||
}
|
||||
@@ -160,13 +165,11 @@ class data_field_base { //base class (text field)
|
||||
* store content of this field type *
|
||||
************************************/
|
||||
function store_data_content($fieldid, $recordid, $value, $name=''){
|
||||
if ($value) {
|
||||
$content = new object;
|
||||
$content->fieldid = $fieldid;
|
||||
$content->recordid = $recordid;
|
||||
$content->content = clean_param($value, PARAM_NOTAGS);
|
||||
insert_record('data_content', $content);
|
||||
}
|
||||
$content = new object;
|
||||
$content->fieldid = $fieldid;
|
||||
$content->recordid = $recordid;
|
||||
$content->content = clean_param($value, PARAM_NOTAGS);
|
||||
insert_record('data_content', $content);
|
||||
}
|
||||
|
||||
/*************************************
|
||||
@@ -392,7 +395,6 @@ function data_numentries($data){
|
||||
* output bool *
|
||||
****************************************************************/
|
||||
function data_add_record($dataid, $groupid=0){
|
||||
|
||||
global $USER;
|
||||
$record->userid = $USER->id;
|
||||
$record->groupid = $groupid;
|
||||
|
||||
Reference in New Issue
Block a user