public function prepareRelatedTableForPersist($field, $data)
    {
        // If the field is nullable, then having associated records is optional.
        if (
            ( ($data == "")   ||
                ($data == null) ||
                (!$data)        ||
                (empty($data)) )
            &&
            ($field['nullable'])
        )
        {
            $data = null;
        }

        return $data;
    }
public function prepareRelatedTableForPersist($field, $data)
    {
        // If the field is nullable, then having associated records is optional.
        if (
            ( ($data == "")   ||
                ($data == null) ||
                (!$data)        ||
                (empty($data)) )
            &&
            ($field['nullable'])
        )
        {
            $data = null;
        }

        return $data;
    }
public function prepareRelatedTableForPersist ( $ field , $ data ) { // If the field is nullable, then having associated records is optional. if ( ( ( $ data == "" ) || ( $ data == null ) || ( ! $ data ) || ( empty ( $ data ) ) ) && ( $ field [ 'nullable' ] ) ) { $ data = null ; } return $ data ; }
Prepare foreign key field for persist.

This is for "one" relationships only, where there is an actual field for the
related table's ID in the primary table.

Basically, the purpose here is to set the data to "null" when there is no value, and
the field is nullable.

@param  array    $fields
@param  array    $data
@return mixed
Prepare foreign key field for persist .