Skip to content

Custom setters are not run for aliased attributes #350

Open
@leightonshank

Description

@leightonshank

If you have an alias defined for an attribute, and also have a custom setter defined for that attribute, then the custom setter is not run when setting the aliased attribute.

Example:

class Person extends ActiveRecord\Model {
    static $alias_attribute = array(
        'name' => 'customer_name'
    )
    public function set_customer_name($customer_name) {
        $this->assign_attribute('customer_name', strtoupper($customer_name));
    }
}

# $person = new Person()
# $person->customer_name = "john doe";
# => "JOHN DOE"
# $person->name = "john doe";
# => "john doe"

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