Last active
December 20, 2015 04:29
-
-
Save wuori/6071677 to your computer and use it in GitHub Desktop.
Accessing a property on an object with a variable property name. Ex: Line #27
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<? | |
/* | |
* Build Select Box | |
* Expects $this->options['display']['data'] to be array('value'=>'label','value'=>'label'...) | |
*/ | |
public function selectdynamic() | |
{ | |
# init row | |
$this->start_row(); | |
$this->build_label(); | |
# get module data | |
$data = DB::table('modules') | |
->where('id','=',$this->options['recordset']) | |
->first(); | |
$data = json_decode($data->module_config); | |
# get table data from module | |
$dataset = DB::table($data->module_table) | |
->orderBy($data->module_sort_col,$data->module_sort_direction) | |
->get(array('id',$data->module_name_col)); | |
# build data array to pass to textarea | |
$select_data = array(); | |
foreach($dataset as $item){ | |
$select_data[$item->id] = $item->{$data->module_name_col}; | |
} | |
# build textarea | |
$this->html .= Form::select( | |
$this->options['colname'], | |
$select_data, | |
$this->form_data['value'], | |
$this->form_data['input_attributes'] | |
); | |
# finalize row | |
$this->end_row(); | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment