Akelos Framework v1 forum archive. This forum is no longer maintained. To report bugs please visit https://github.com/akelos/akelos/issues
    • CommentAuthorupupnaway
     

    Hello,

    I'm trying to add a price column to an existing table

    class ProductInstaller extends ...
    
    // Previous migrations
    
    function up_3()
    {
        $this->addColumn ('products', "
            price decimal(6,2)
        ");
    }
    
    // More migration code...
    

    I ran the migration and the price column was added as a decimal type,but the (6,2) condition didn't pass. Am I missing a set of parentheses or something?

    Pardon my noobness.

    Thanks,

    •  
      CommentAuthorbermi
     

    try with

    price decimal(6.2)
    
    • CommentAuthorupupnaway
     
    Thanks Bermi,

    That worked, somewhat. It stores two decimal places in the database, but it doesn't accept anything after the decimals.

    ex.

    When I input price: 29.50

    What shows up on my listing page (via scaffold) is just 29. No decimals.
    What shows up in my db table(price column) is 29.00. Not showing the 50 after the decimal.

    ???
    • CommentAuthorkatun
     

    i think you must take the float datatype instead of the decimal datatype. So it works for me.

    price float 10.2
    
    • CommentAuthorupupnaway
     
    nice, it works.

    Thanks katun
    • CommentAuthordemaio
     
    Does scaffolding support decimals?
    After placing following in my installer :

    price decimal(6.2)

    everything seems to be ok in the database, the column in it is created correctly. The thing is, that after generating scaffolding for this table, all fields of it are in place but the decimal price field.
    In the _form.tpl the scaffold command creates something like :

    <?php echo $active_record_helper->input('item', 'price') ?>

    which next is not rendered by my browser ... The field is neither visible , nor label tag is placed in the source code of the page.
    After adding such and item to the table in my database, price field gets value of 0.00

    Using floats or integers seems to be much safer option in this case.

    Any opinions on this?

    Best regards

    demaio

    -----------
    • CommentAuthorinsanet
     
    i used $form_helper->text_field('item', 'price');
    and that worked.
    (this is from the top of my head, im not pretty sure if that was the correct helper, but im sure i used text_field)