I am building a module and I am looping thru data to set a value for each key, to be used as EE template tags.
foreach($missing_fields as $field)
{
$count++;
$vars = array(
'field_id' => $field->m_field_id,
'field_name' => $field->m_field_name,
'field_label' => $field->m_field_label,
'field_type' => $field->m_field_type,
'field_list_items' => format_list_items($field->m_field_list_items),
'count' => $count,
'total_fields' => count($missing_fields),
);
$out .= $this->EE->TMPL->parse_variables_row($this->EE->TMPL->tagdata, $vars);
}
return $out;
In the template, I want to display the field's label, which works, when it is a select field (notice conditional), I want to be able to loop thru the values.
{exp:module_name:form}
<label>{field_label}</label>
{if field_type == "select"}
<select name="{field_name}"
{field_list_items}
{!-- loop thru each select value --}
<option value="{select_item}">{select_item}</option>
{/field_list_items}
</select>
{/if}
{/exp:module_name:form}
I created a format_list_items helper function that just returns a basic array of data for testing purposes.
return array('value 1', 'value 2');
I looked at the user module to see if they did anything like this in the profile edit functions & also looked at EE's myaccount.php line 364 (in edit_profile function).