⚠ 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

how to add field of db in add form with some default value



Vishal Kulshrestha

Vishal Kulshrestha
  • profile picture
  • Member

Posted 09 April 2016 - 09:06 AM

$crud = $this->generate_crud('courses');
            $crud->set_relation('admin_id', 'admin_users', 'username');
            $this->mTitle = 'Courses';
            $this->render_crud();
 
In ,set_relation('admin_id', 'admin_users', 'username');
I want to display default value instead the value of tables.... 
 

 


buoncri

buoncri
  • profile picture
  • Member

Posted 12 April 2016 - 07:22 AM

I think you have to insert a callback and manually generate the field with all you need (html too).


        # callback in the main function
        $crud->callback_add_field('n_prop_spesa', array($this, '_aggiungi_documento'));


Then ... (end part of the callback function)

        # crea la stringa di ritorno con il valore del campo numero proposta di spesa  compilato
        $stringa_di_ritorno = '<input type="text" maxlength="50" value="' . strval(++$row["numeretto"]) . '" name="n_prop_spesa" style="width:462px">' . "\n";

        //return a string like ... '<input type="text" maxlength="50" value="1111" name="n_prop_spesa" style="width:462px">';
        return ($stringa_di_ritorno);