crater
crater copied to clipboard
Custom fields do not load existing values from database
I've been using Crater for many years and it is great. Thank you SO much to the developer! However there is a persistent bug I've encountered with custom fields. I am using them on the "customer" model.
- Custom field "required" toggle does not work (always enabled)
- Setting is_required boolean in custom_fields table in database does not fix
- When editing customer, values saved to custom fields do not load into text boxes
To test this bug further, I just added a boolean to the invoices model. I see the toggle on my invoices, and I can set it to "on" or "off," which correctly sets the flag in the database. But when I edit the invoice, the toggle does not correctly load the existing value from the database. This requires re-setting the flag every time an edit is made. Therefore I see 2 bugs here:
- "Required" value not respect
- Forms do not load existing values from database (tested on customer and invoice model)
I have been using crater recently, and have observed this bug.
Has anyone had any success with custom values?
I believe it has something to do with this code which is used to update the field values, but I can't say for sure:
public function updateCustomFields($customFields)
{
foreach ($customFields as $field) {
if (! is_array($field)) {
$field = (array)$field;
}
$customField = CustomField::find($field['id']);
$customFieldValue = $this->fields()->firstOrCreate([
'custom_field_id' => $customField->id,
'type' => $customField->type,
'company_id' => $this->company_id,
]);
$type = getCustomFieldValueKey($customField->type);
$customFieldValue->$type = $field['value'];
$customFieldValue->save();
}
}
Hi @mohitpanjwani, would it be possible to get guidance on this issue? From what I can tell it is not really possible to properly implement custom fields until this is resolved. Thanks so much in advance for your help.
Hi @mohitpanjwani, would it be possible to get guidance on this issue? From what I can tell it is not really possible to properly implement custom fields until this is resolved. Thanks so much in advance for your help.
Confirming this issue! Very difficult to workaround
Hi, Any solution for this bug please
Hi, Any solution for this bug please
@mohitpanjwani please help us!
Is this project abandoned? We have not been able to use custom fields at all while we are awaiting a solution to this. We'd happily donate to have it fixed.