Skip to content

Commit dc069cf

Browse files
committed
implement upstream fix for grocery-crud/pull/491 with missinig fields
* fix issue when we use set_read_fields with a column that doesn't exist at the database * is a backport fix grocery-crud/commit/9bf6e3385fc90eb7f7dc3b875cd281211c72ea45 * only was adition of new funtion check.. so dont trast the resto of code * update chagelog property
1 parent b56658d commit dc069cf

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

application/libraries/Grocery_CRUD.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,35 @@ public function get_field_types()
195195
}
196196
}
197197

198+
if (!empty($this->read_fields)) {
199+
foreach ($this->read_fields as $field_object) {
200+
$field_name = isset($field_object->field_name) ? $field_object->field_name : $field_object;
201+
202+
if (!isset($types[$field_name]))//Doesn't exist in the database? Create it for the CRUD
203+
{
204+
$extras = false;
205+
if ($this->change_field_type !== null && isset($this->change_field_type[$field_name])) {
206+
$field_type = $this->change_field_type[$field_name];
207+
$extras = $field_type->extras;
208+
}
209+
210+
$field_info = (object)array(
211+
'name' => $field_name,
212+
'crud_type' => $this->change_field_type !== null && isset($this->change_field_type[$field_name]) ?
213+
$this->change_field_type[$field_name]->type :
214+
'string',
215+
'display_as' => isset($this->display_as[$field_name]) ?
216+
$this->display_as[$field_name] :
217+
ucfirst(str_replace("_", " ", $field_name)),
218+
'required' => !empty($this->required_fields) && in_array($field_name, $this->required_fields) ? true : false,
219+
'extras' => $extras
220+
);
221+
222+
$types[$field_name] = $field_info;
223+
}
224+
}
225+
}
226+
198227
$this->field_types = $types;
199228

200229
return $this->field_types;

change_log.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
v1.6.3.1
2-
- Updating jQuery version to 1.12.4 that still supports any web browser
2+
- Updating jQuery version to 1.12.4 that still supports any web browser
3+
- #491: Fixing issue when we use set_read_fields with a column that doesn't exist at the database
34
v1.6.3
45
- #465: Translation for Spanish Uruguay by @mlopezcoria
56
- #470: Update Polish translation by @tikky

0 commit comments

Comments
 (0)