[ANSWERED] change_field_type "enum" and values as array
- Single Page
Posted 05 March 2012 - 10:42 AM
Thanks a lot.
Posted 06 March 2012 - 22:55 PM
I think that a temporary table will make your life easier. I want to add this feature at a future release to have for example:
$crud->change_field_type('jobTitle', 'enum', array('test','test1','test2'));
But still I don't have it so a quick solution is a temporary table as you said with set_relation.
Posted 07 March 2012 - 20:07 PM
I want to add this feature at a future release to have for example:
$crud->change_field_type('jobTitle', 'enum', array('test','test1','test2'));
[/quote]
It's a great idea!
Posted 15 March 2012 - 14:55 PM
$crud->callback_field('column', array($this, 'field_callback'));
$crud->render().....
public function field_callback($value = NULL)
{
$options = array('a', 'b', 'c');
$option_tag = '';
foreach($options as $option)
{
$attribute = 'value="'.$option.'"';
if ($option == $value)
{
$attribute .= ' selected="selected"';
}
$option_tag .= "<option $attribute>$option</option>";
}
return '<select name="column">'.$option_tag.'</select>';
}
Posted 07 May 2012 - 19:38 PM
Did u try callback_field() function?
$crud->callback_field('column', array($this, 'field_callback'));
$crud->render().....
public function field_callback($value = NULL)
{
$options = array('a', 'b', 'c');
$option_tag = '';
foreach($options as $option)
{
$attribute = 'value="'.$option.'"';
if ($option == $value)
{
$attribute .= ' selected="selected"';
}
$option_tag .= "<option $attribute>$option</option>";
}
return '<select name="column">'.$option_tag.'</select>';
}
[/quote]
Worked like a charm!
But it would be good the
$crud->change_field_type('jobTitle','enum', array('test','test1','test2'));
Thanks!
Posted 25 May 2012 - 18:04 PM
$this->crud->change_field_type('lang', 'enum', array( 'English' => 'en', 'Russian' => 'ru' ));
and appears like:
<select>
<option value="en">English</option>
...
Thanks!
Posted 26 May 2012 - 20:09 PM
Posted 27 May 2012 - 07:37 AM
[quote name='web-johnny' timestamp='1338062961' post='1997'] Yes you can download the latest version from github: https://github.com/s.../zipball/master [/quote]
Posted 27 August 2012 - 14:43 PM
Posted 18 February 2014 - 22:22 PM
now since I was able to get the static add one, how can i show it in the list without "set_relation"??
$crud->callback_column('group_exercise_id',array($this,'list_group_exercise_id'));
public function list_group_exercise_id($value, $row)
{
$name = '';
if($value==1){
$name = 'Text 1';
}
if($value==2){
$name = 'Text 2';
}
return $name;
}