⚠ 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 forum is read-only and soon will be archived. ⚠


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

link callback_column

  • Please log in to reply
3 replies to this topic

#1 vladbutterfly

vladbutterfly

    Member

  • Members
  • PipPip
  • 16 posts

Posted 03 May 2013 - 02: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 ;



#2 victor

victor

    grocery CRUD Hero

  • Advanced Member
  • PipPipPip
  • 967 posts

Posted 03 May 2013 - 08:28 PM

what result do you have?

#3 kelli

kelli

    Newbie

  • Members
  • Pip
  • 9 posts

Posted 05 December 2013 - 02: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.



#4 Amit Shah

Amit Shah

    grocery CRUD Master

  • Advanced Member
  • PipPipPip
  • 1,192 posts

Posted 05 December 2013 - 05: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







Also tagged with one or more of these keywords: link, callback_column

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users