⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Get a correct output after using callback_field



Mikhail Neofitov

Mikhail Neofitov
  • profile picture
  • Member

Posted 13 March 2014 - 08:30 AM

After select all i need in select "Dish" and typing data to Count, I click on "Save" and Grocery Crud returns message "The order_items field is required", but I want to insert a string like "Dish <dish_name> Count 5 Price 50" into database.

Is it possible?

 

Sorry for my english.

...
$crud
...
->callback_field('order_items',array($this,'items'))
->required_fields('order_items');
...

    function items($pk,$row)
    {
        $dishes = $this->db->get('catalog__dishes')->result();
        $str = '';
        foreach ($dishes as $line)
            if ($line->dish_active != 0)
                $str .= '<option value="' . $line->dish_id .'"' . '>' . $line->dish_name . '</option>';
        return '<table id="items_table">'
        . '<tr>'
                . 'Dish <select class="item_select" id="row_1_items">'
            .$str
            .'</select>'
                . 'Count <input class="item_select" id="row_1_count" type="text" onkeypress="return event.charCode >= 48 && event.charCode <= 57" style="width:150px">'
                . 'Price <input class="item_select" id="row_1_price" type="text" style="width:150px" disabled>'
                . '</tr>'
                . '</table>';
    }   

 

 


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 16 March 2014 - 06:39 AM

well i believe it is quite possible and the same can be achieved by using a simple callback_before_insert method.. .here u modify the value of the field u want to alter b4 u insert.