hungrykoala
hungrykoala

Reputation: 1083

SugarCRM v6.5 anything after $bean->save stops working

I have this code:

function saveField($field, $id, $module, $value)
{

    $bean = BeanFactory::getBean($module, $id);

    if (is_object($bean) && $bean->id != "") {

        if ($bean->field_defs[$field]['type'] == "multienum") {
            $bean->$field = encodeMultienumValue($value);
        }else if ($bean->field_defs[$field]['type'] == "relate" || $bean->field_defs[$field]['type'] == 'parent'){
            $save_field = $bean->field_defs[$field]['id_name'];
            $bean->$save_field = $value;
            if ($bean->field_defs[$field]['type'] == 'parent') {
                $bean->parent_type = $_REQUEST['parent_type'];
                $bean->fill_in_additional_parent_fields(); // get up to date parent info as need it to display name
            }
        }else{
            $bean->$field = $value;
        }
        //return here will work
        $bean->save(); //this works
        //nothing works here
        return getDisplayValue($bean, $field);
    } else {
        return false;
    }

}

The problem here is that anything under

$bean->save()

will not work. But I know that save is working as the values are being updated. So how can I debug this problem?

I already tried:

return var_dump($bean->save());
return print_r($bean->save());
if($bean->save()){
 return "1";
}else{
 return "2";
}

And none of those in the above worked I still get nothing in my return.

Upvotes: 0

Views: 344

Answers (2)

pauel
pauel

Reputation: 906

Try using xdebug, it should allow you to investigate further into the save method that fails.

Upvotes: 0

egg
egg

Reputation: 1756

There is likely something such as an after_save logic hook that is executing and either causing a fatal error or doing an exit.

Upvotes: 1

Related Questions