Skip to content

Commit 6d74ded

Browse files
committed
ensuring that file upload fields can be set to uneditable
1 parent 261e118 commit 6d74ded

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

ajaxCRUD.class.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
*/
77

88
/************************************************************************/
9-
/* ajaxCRUD.class.php v8.92 */
9+
/* ajaxCRUD.class.php v8.93 */
1010
/* =========================== */
1111
/* Copyright (c) 2013 by Loud Canvas Media (arts@loudcanvas.com) */
1212
/* http://www.ajaxcrud.com by http://www.loudcanvas.com */
@@ -740,7 +740,7 @@ function setFileUpload($field_name, $destination_folder, $relative_folder = "",
740740
}
741741

742742
//the filenames that are saved are not editable
743-
$this->disallowEdit($field_name);
743+
//$this->disallowEdit($field_name);
744744

745745
//have to add the row via POST now
746746
$this->ajax_add = false;
@@ -1643,13 +1643,13 @@ function showTable(){
16431643
}
16441644

16451645
//don't allow uneditable fields (which usually includes the primary key) to be editable
1646-
if ( !$canRowBeUpdated || ( ($this->fieldInArray($field, $this->uneditable_fields) && (!is_numeric($found_category_index))) ) ){
1646+
if ( !$canRowBeUpdated || $this->fieldInArray($field, $this->file_uploads) || ( ($this->fieldInArray($field, $this->uneditable_fields) && (!is_numeric($found_category_index))) ) ){
16471647

16481648
$table_html .= "<td>";
16491649

16501650
$key = array_search($field, $this->display_fields);
16511651

1652-
if ($this->fieldInArray($field, $this->file_uploads)){
1652+
if ($this->fieldInArray($field, $this->file_uploads) && !$this->fieldInArray($field, $this->uneditable_fields)){
16531653

16541654
//a file exists for this field
16551655
$file_dest = "";
@@ -1663,8 +1663,7 @@ function showTable(){
16631663
$table_html .= $this->showUploadForm($field, $file_dest, $id);
16641664
$table_html .= "</div>\n";
16651665
}
1666-
1667-
if ($cell_data == ''){
1666+
else{
16681667
$table_html .= "<span id='text_" . $field . $id . "'><a style=\"font-size: 9px;\" href=\"javascript:\" onClick=\"document.getElementById('file_$field$id').style.display = ''; document.getElementById('text_$field$id').style.display = 'none'; \">Add File</a></span> \n";
16691668

16701669
$table_html .= "<div id='file_" . $field. $id . "' style='display:none;'>\n";

examples/example3.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@
7070

7171
#allow picture to be a file upload
7272
$tblFriend->setFileUpload('fldPicture','uploads/','uploads/');
73+
//$tblFriend->disallowEdit("fldPicture");
7374

7475
#format field output
7576
$tblFriend->formatFieldWithFunction('fldOwes', 'addDollarSign');
@@ -80,7 +81,7 @@
8081
#modify field with class
8182
$tblFriend->modifyFieldWithClass("fldDateMet", "datepicker");
8283
$tblFriend->modifyFieldWithClass("fldZip", "zip required");
83-
$tblFriend->modifyFieldWithClass("fldPhone", "phone");
84+
$tblFriend->modifyFieldWithClass("fldPhone", "phone required");
8485
$tblFriend->modifyFieldWithClass("fldEmail", "email");
8586

8687
#set allowable values for certain fields

0 commit comments

Comments
 (0)