⚠ 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

add a new record with link field ..no error and on the same time operation failed



vladbutterfly

vladbutterfly
  • profile picture
  • Member

Posted 03 May 2013 - 14:01 PM

Hi GCrud'ers'

I want to add a field as a link to a page,I used the callback_column as mentioned in the GC documentation..But the edit and add operation gives no result and on the same time no errors

Im new in GC and I dont know where my error is

 

 

My controller code

 public function project_management()
     {
        $crud = new grocery_CRUD();
        $crud->set_table('project');
        $crud->set_subject('Project');

         $crud->set_relation('customer_id', 'customer', 'name');
        $crud->display_as('customer_id','Customer Name');
         $crud->set_relation('manager_id', 'resource', 'first_name');
        $crud->display_as('customer_id','Customer Name');
        $crud->set_relation('project_status_id', 'project_status', 'id');
        $crud->display_as('project_status_id','Status Identifier');
             $crud->add_fields('description','manager_id','customer_id','customer_group','project_status_id','project_status_text','redmine_id','change_date');
        $crud->callback_column('redmine_id',array($this,'_callback_redmine_url'));
        
        $crud->callback_add_field('customer_group', array($this, 'add_field_callback_1'));
        $crud->callback_before_insert(array($this, '_callback_before_insert'));
        $crud->callback_add_field('project_status_text', array($this, 'add_field_callback_2'));
        $crud->callback_before_insert(array($this, '_callback_before_insert_2'));

        $output = $crud->render();
        $this->_example_output($output);
        

    }

 



    
    
public function _callback_redmine_url($value, $row)
{
  return "<a href='".site_url('main/project_management/'.$row->manager_id)."'>'.$row->manager_id.'</a>";
}

 

database

 

 

CREATE TABLE IF NOT EXISTS `project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_status_id` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
  `manager_id` int(11) NOT NULL,
  `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `customer_id` int(11) NOT NULL,
  `redmine_id` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
  `change_date` datetime DEFAULT NULL,
  `attachment_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_2FB3D0EE7ACB456A` (`project_status_id`),
  KEY `IDX_2FB3D0EE783E3463` (`manager_id`),
  KEY `KundenProjekte` (`customer_id`),
  KEY `redmine_id` (`redmine_id`),
  KEY `attachment_id` (`attachment_id`),
  KEY `attachment_id_2` (`attachment_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;


victor

victor
  • profile picture
  • Member

Posted 03 May 2013 - 20:28 PM

what result do you have?

kelli

kelli
  • profile picture
  • Member

Posted 05 December 2013 - 14:17 PM

Hi GCrud'ers'

I want to add a field as a link to a page,I used the callback_column as mentioned in the GC documentation..But the edit and add operation gives no result and on the same time no errors

Im new in GC and I dont know where my error is

 

 

My controller code

 public function project_management()
     {
        $crud = new grocery_CRUD();
        $crud->set_table('project');
        $crud->set_subject('Project');

         $crud->set_relation('customer_id', 'customer', 'name');
        $crud->display_as('customer_id','Customer Name');
         $crud->set_relation('manager_id', 'resource', 'first_name');
        $crud->display_as('customer_id','Customer Name');
        $crud->set_relation('project_status_id', 'project_status', 'id');
        $crud->display_as('project_status_id','Status Identifier');
             $crud->add_fields('description','manager_id','customer_id','customer_group','project_status_id','project_status_text','redmine_id','change_date');
        $crud->callback_column('redmine_id',array($this,'_callback_redmine_url'));
        
        $crud->callback_add_field('customer_group', array($this, 'add_field_callback_1'));
        $crud->callback_before_insert(array($this, '_callback_before_insert'));
        $crud->callback_add_field('project_status_text', array($this, 'add_field_callback_2'));
        $crud->callback_before_insert(array($this, '_callback_before_insert_2'));

        $output = $crud->render();
        $this->_example_output($output);
        

    }

 


    
    
public function _callback_redmine_url($value, $row)
{
  return "<a href='".site_url('main/project_management/'.$row->manager_id)."'>'.$row->manager_id.'</a>";
}

 

database

 

 

CREATE TABLE IF NOT EXISTS `project` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `project_status_id` varchar(5) COLLATE utf8_unicode_ci NOT NULL,
  `manager_id` int(11) NOT NULL,
  `description` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
  `customer_id` int(11) NOT NULL,
  `redmine_id` varchar(45) COLLATE utf8_unicode_ci DEFAULT NULL,
  `change_date` datetime DEFAULT NULL,
  `attachment_id` int(11) NOT NULL,
  PRIMARY KEY (`id`),
  KEY `IDX_2FB3D0EE7ACB456A` (`project_status_id`),
  KEY `IDX_2FB3D0EE783E3463` (`manager_id`),
  KEY `KundenProjekte` (`customer_id`),
  KEY `redmine_id` (`redmine_id`),
  KEY `attachment_id` (`attachment_id`),
  KEY `attachment_id_2` (`attachment_id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=9 ;

Whien i tried to do this i took this result(althought i addapt to db my own data) :

 

404 Page Not Found

The page you requested was not found.


Amit Shah

Amit Shah
  • profile picture
  • Member

Posted 05 December 2013 - 17:52 PM

Hi there

 

Can you share the exact url that gets generated out of it as the result.. and second thing will like you to do is.. cross check with the system whether the said url is accessible into the system.

 

If so - great go ahead with the same.. if not.. fix up with the url...

 

Secondly - in the code shared i don't see any piece of code that accepts the manager id as a parameter and take necessary action on the same..

Will recommend you add the right course of action in the direction for the desired solution