Skip to content
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

Scaffolding is incompatible with getter/setter style models #79

Closed
chuyskywalker opened this issue May 19, 2013 · 0 comments · Fixed by #139
Closed

Scaffolding is incompatible with getter/setter style models #79

chuyskywalker opened this issue May 19, 2013 · 0 comments · Fixed by #139

Comments

@chuyskywalker
Copy link
Contributor

Example table:

CREATE TABLE `usersTest` (
  `uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `email` varchar(255) NOT NULL,
  PRIMARY KEY (`uid`),
  UNIQUE KEY `email` (`email`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

Example model:

<?php


class Userstest extends \Phalcon\Mvc\Model
{

    /**
     * @var integer
     */
    protected $uid;

    /**
     * @var string
     */
    protected $email;

    /**
     * Method to set the value of field uid
     *
     * @param integer $uid
     */
    public function setUid($uid)
    {
        $this->uid = $uid;
        return $this;
    }

    /**
     * Method to set the value of field email
     *
     * @param string $email
     */
    public function setEmail($email)
    {
        $this->email = $email;
        return $this;
    }

    /**
     * Returns the value of field uid
     *
     * @return integer
     */
    public function getUid()
    {
        return $this->uid;
    }

    /**
     * Returns the value of field email
     *
     * @return string
     */
    public function getEmail()
    {
        return $this->email;
    }

    /**
     * Validations and business logic
     */
    public function validation()
    {

        $this->validate(
            new Email(
                array(
                    "field"    => "email",
                    "required" => true,
                )
            )
        );
        if ($this->validationHasFailed() == true) {
            return false;
        }
    }

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSource('usersTest');
    }

}

Examples of failing usage in scaffolding:

            $this->view->uid = $usersTest->uid;

            Tag::setDefault("uid", $usersTest->uid);
            Tag::setDefault("email", $usersTest->email);
        $usersTest = new Userstest();

        $usersTest->uid = $this->request->getPost("uid");
        $usersTest->email = $this->request->getPost("email", "email");

Etc, you get the idea.

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

Successfully merging a pull request may close this issue.

1 participant