Question

I have a combobox and I don't know how the value options is Populated. How the method profile_manager_get_categorized_group_fields() works?

// retrieve group fields
$group_fields = profile_manager_get_categorized_group_fields();

$ramosAtuacao = array('' => '-- Selecione --');
$opcoesObjetivos = $opcoesFranquia = array();
foreach($group_fields['fields'] as $field){

switch ( $field->metadata_name ) {
case 'ramoatuacao':
$ramosAtuacao = array_merge( $ramosAtuacao, $field->getOptions() );
break;
case 'franquia':
$opcoesFranquia = $field->getOptions();
break;
}
}

and

<?php echo elgg_view("input/dropdown", array(
'name' => 'ramoatuacao',
'value' => $vars['entity']->ramoatuacao,
'options' => $ramosAtuacao
)); ?>
Was it helpful?

Solution

First of all you got your answer here: http://community.elgg.org/discussion/view/1648483/trying-understand-code

Secondly, read comments in file views/default/input/dropdown.php. If you don't know why this file gets mapped to a view name, read http://docs.elgg.org/wiki/Engine/Views

According to question itself, I understand you actually ask for 3 things:

  • how/what view handles options passed in options parameter: It's array of values to be put into select. If you use options_values, you can pass associative array to have different keys from labels
  • how contents of $ramosAtuacao are generated: Well, you have it mostly in the code you've pasted and function implementation: https://github.com/ColdTrick/profile_manager/blob/master/lib/functions.php#L330
  • how to change result of profile_manager_get_categorized_group_fields: Through the admin interface of profile_manager or via plugin hook depending on what you want to do.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top