Skip to content

Custom setters are not run for aliased attributes #350

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
leightonshank opened this issue Jul 8, 2013 · 2 comments
Open

Custom setters are not run for aliased attributes #350

leightonshank opened this issue Jul 8, 2013 · 2 comments

Comments

@leightonshank
Copy link

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"
@cvanschalkwijk
Copy link
Collaborator

@leightonshank could you submit a pull request for this change?

@leightonshank
Copy link
Author

There is already a PR for this #351

@koenpunt koenpunt mentioned this issue Dec 9, 2014
27 tasks
koenpunt added a commit that referenced this issue Jan 19, 2015
…ibute

Allow custom setter methods to run for aliased attributes (fixes #350)
koenpunt added a commit that referenced this issue Jun 3, 2017
…ibute

Allow custom setter methods to run for aliased attributes (fixes #350)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants