Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorkkrzyzak
    I would like to create some checkbox fields, then before save serialize its,and store as serialized data. However, I don't know how.
    I'm trying to use beforeSave() function:
    name of my form fields are:
    Article[source][foo] , Article[source][bar] etc...
    function beforeSave(){
    $source = $this->getAttribute('source');
    $source= serialize($source);
    // return false;
    How can I use this function, and serialize my data?

    You just need to declare the attributes you want to serialize on your active record and they'll be serialized/unserialized for you automatically

    class Article extends ActiveRecord{
        public $serialize = 'source';
    • CommentAuthorkkrzyzak
    Hi Bermi!
    I've got
    <input type="checkbox" name="Article[sources][foo]" />
    and sources column in articles table.
    in article model:
    class Article extends ActiveRecord
    public $serialize = 'sources';

    And after create, I've got all my columns serialized, not only sources... why?