Jump to content


How to use set the select dropdown value field other that the primary value

select dropdown

  • Please log in to reply
3 replies to this topic

#1 Flashy

Flashy

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 27 January 2016 - 02:25 AM

When I use the "set_relation" function, how can I use a different database column value for the selects option value that is output?

 

Is the default valued used when rendered the tables Primary key value? - how can I use a value from another column?

 

 

My Code:

 

$this->crud->set_relation('show','statuses','title', array('group' => 'yn'));

 

This is the database structure of the statuses table:

 

CREATE TABLE `statuses` (
  `id` int(4) NOT NULL AUTO_INCREMENT,
  `title` varchar(100) NOT NULL,
  `slug` varchar(100) NOT NULL,
  `value` int(4) NOT NULL DEFAULT '0',
  `group` varchar(100) NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;

 

 

I want to use the "value" column results not the id column

 



#2 Flashy

Flashy

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 28 January 2016 - 05:11 AM

Worked it out incase anybody else needs to know:

 

Set the primary key of the table before calling set_relations...

 

$crud->set_primary_key('value','statuses');
$crud->set_relation('show_in_navi','statuses','title', array('group' => 'yn'));

 



#3 Flashy

Flashy

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 28 January 2016 - 05:25 AM

 

Worked it out incase anybody else needs to know:

 

Set the primary key of the table before calling set_relations...

 

$crud->set_primary_key('value','statuses');
$crud->set_relation('show_in_navi','statuses','title', array('group' => 'yn'));

 

So it seems that when you do this, it doubles up the data being returned, so I still need an answer to this...



#4 Dennis Ayala

Dennis Ayala

    Newbie

  • Members
  • Pip
  • 3 posts

Posted 10 February 2016 - 11:29 PM

So it seems that when you do this, it doubles up the data being returned, so I still need an answer to this...

 

I'm interested to know the answer for this question. Anyone?







0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users