Skip to content
This repository was archived by the owner on Apr 1, 2022. It is now read-only.
This repository was archived by the owner on Apr 1, 2022. It is now read-only.

Current populate() does not account for setting property value back to null #5

@crazedVic

Description

@crazedVic

I know you probably don't use this code any more but just in case you do. Found an interesting bug.

public function populate($params)
    {
        $columns = self::getColumns();
        foreach ($columns as $column) {
            if (isset($params[$column['Field']])) {
                $c = $column['Field'];
                $this->$c = $params[$column['Field']];
            }
        }
        return $this;
    }

i changed it to this, i was trying to set date field back to null and it didn't store the change, this fixed it:

public function populate($params)
    {
        $columns = self::getColumns();

        foreach ($columns as $column) {
            if (array_key_exists($column['Field'], $params)) {
                $c = $column['Field'];
                $this->$c = $params[$column['Field']];
            }
        }
        return $this;
    }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions