Skip to content

Instantly share code, notes, and snippets.

@wuori
Last active December 20, 2015 04:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wuori/6071677 to your computer and use it in GitHub Desktop.
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
<?
/*
* 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