Class Phalcon\Mvc\Model\Message

implements Phalcon\Mvc\Model\MessageInterface

Source on GitHub

Encapsulates validation info generated before save/delete records fails


use Phalcon\Mvc\Model\Message as Message;

class Robots extends \Phalcon\Mvc\Model
    public function beforeSave()
        if ($this->name === "Peter") {
            $text  = "A robot cannot be named Peter";
            $field = "name";
            $type  = "InvalidValue";

            $message = new Message($text, $field, $type);



public __construct (string $message, [string | array $field], [string $type], [Phalcon\Mvc\ModelInterface $model], [int | null $code])

Phalcon\Mvc\Model\Message constructor

public setType (mixed $type)

Sets message type

public getType ()

Returns message type

public setMessage (mixed $message)

Sets verbose message

public getMessage ()

Returns verbose message

public setField (mixed $field)

Sets field name related to message

public getField ()

Returns field name related to message

public setModel (Phalcon\Mvc\ModelInterface $model)

Set the model who generates the message

public setCode (mixed $code)

Sets code for the message

public getModel ()

Returns the model that produced the message

public getCode ()

Returns the message code

public __toString ()

Magic __toString method returns verbose message

public static __set_state (array $message)

Magic __set_state helps to re-build messages variable exporting

Interface Phalcon\Mvc\Model\MessageInterface

Source on GitHub


abstract public setType (mixed $type)

abstract public getType ()

abstract public setMessage (mixed $message)

abstract public getMessage ()

abstract public setField (mixed $field)

abstract public getField ()

abstract public __toString ()

abstract public static __set_state (array $message)