crater icon indicating copy to clipboard operation
crater copied to clipboard

Custom fields do not load existing values from database

Open profiteroles1 opened this issue 2 years ago • 9 comments

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

profiteroles1 avatar May 16 '22 08:05 profiteroles1

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)

profiteroles1 avatar May 16 '22 09:05 profiteroles1

I have been using crater recently, and have observed this bug.

anweshandev avatar May 24 '22 17:05 anweshandev

Has anyone had any success with custom values?

profiteroles1 avatar Jun 01 '22 19:06 profiteroles1

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();
        }
    }

profiteroles1 avatar Jun 20 '22 00:06 profiteroles1

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.

profiteroles1 avatar Aug 01 '22 17:08 profiteroles1

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

prohtex avatar Oct 27 '22 02:10 prohtex

Hi, Any solution for this bug please

aelabbassi avatar Jan 10 '23 10:01 aelabbassi

Hi, Any solution for this bug please

@mohitpanjwani please help us!

prohtex avatar Jan 26 '23 05:01 prohtex

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.

profiteroles1 avatar Feb 22 '24 21:02 profiteroles1