title: Joomla 2.5 get Options from a field (list)
body: <p>I can't believe I am asking a question like this. I was searching for 4 hours on google just to find the solution. I found about 10000 pages on how to create a field in xml but not anyone on how to call the options in a php code.</p>
  <p>What I want is an array of the options from this field:</p>
  <pre><code>&lt;field name=&quot;field8&quot; type=&quot;jevcflist&quot; default=&quot;-1&quot; label=&quot;Alter&quot; required=&quot;1&quot; allowoverride=&quot;0&quot; filter=&quot;1&quot; access=&quot;0&quot; size=&quot;1&quot; style=&quot;min-width: 123px;&quot;&gt;
      &lt;option value=&quot;3&quot;&gt;3&lt;/option&gt;
      &lt;option value=&quot;4&quot;&gt;4&lt;/option&gt;
      &lt;option value=&quot;5&quot;&gt;5&lt;/option&gt;
      &lt;option value=&quot;6&quot;&gt;6&lt;/option&gt;
  &lt;/field&gt;
  </code></pre>
  <p>I tried with</p>
  <pre><code>$form = &amp;JForm::getInstance('customfields', $xmlfile);
  // get the age list                    
  $field = $form-&gt;getField('field8');
  </code></pre>
  <p>when I <code>var_dump</code> the data of <code>$field</code>:</p>
  <pre><code>object(JFormFieldJevcflist)[428]
    protected 'node' =&gt; null
    protected 'type' =&gt; string 'List' (length=4)
    protected 'description' =&gt; string '' (length=0)
    protected 'element' =&gt; 
      object(JXMLElement)[427]
        public '@attributes' =&gt; 
          array (size=11)
            'name' =&gt; string 'field8' (length=6)
            'type' =&gt; string 'jevcflist' (length=9)
            'default' =&gt; string '-1' (length=2)
            'label' =&gt; string 'Alter' (length=5)
            'required' =&gt; string '1' (length=1)
            'allowoverride' =&gt; string '0' (length=1)
            'filter' =&gt; string '1' (length=1)
            'access' =&gt; string '0' (length=1)
            'size' =&gt; string '1' (length=1)
            'style' =&gt; string 'min-width: 123px;' (length=17)
            'class' =&gt; string 'required' (length=8)
        public 'option' =&gt; 
          array (size=10)
            0 =&gt; string '3' (length=11)
            1 =&gt; string '4' (length=11)
            2 =&gt; string '5' (length=11)
            3 =&gt; string '6' (length=11)
          
  </code></pre>
  <p>So I tried with <code>$field-&gt;element-&gt;option</code> but it does not work at all.
  I should also have the option value...
  It worked with <strong>JParameter</strong> in 1.5 but how is this done in 2.5?</p>
  <p>Edit:
  I need this in a filter file.</p>
  <p>Edit2:
  As requested the code of Joomla 1.5:</p>
  <pre><code>$hasage = false;
          
          $params = new JParameter(null, $xmlfile);
      
          foreach($params-&gt;_xml[&quot;_default&quot;]-&gt;children() as $n) {
              if($n-&gt;_attributes['label']==&quot;Alter&quot;) {
                  $hasage = true;
                  //foreach($n-&gt;children() as $param){
                  foreach($n-&gt;_children as $param){
                      $options[] = JHTML::_('select.option',
                           $param-&gt;_attributes['value'], 
                           $param-&gt;_data, //&quot;Ab &quot;.$param-&gt;_attributes['value'].&quot; Jahren&quot;,
                           &quot;value&quot;,
                           &quot;customfieldage&quot;);
                  }
              }
          }
  
          if (!$hasage){
              $filterList[&quot;title&quot;] = &quot;&quot;;
              $filterList[&quot;html&quot;] = &quot;&quot;;
              return $filterList;
          }
          
          /*for($i = 3; $i &lt; 13; $i++) {
              $options[] = JHTML::_('select.option', $i, &quot;Ab &quot;.$i.&quot; Jahren&quot;, &quot;value&quot;, &quot;customfieldage&quot;);
          }*/
          
          $filterList[&quot;html&quot;] = JHTML::_('select.genericlist',
                                  $options,
                                  $this-&gt;filterType.'_fv',
                                  'onchange=&quot;this.form.submit();&quot;',
                                  'value',
                                  'customfieldage',
                                  $this-&gt;filter_value);
          
          
          
          $script = &quot;JeventsFilters.filters.push({id:'&quot;.$this-&gt;filterType.&quot;_fv', value:-1});&quot;;
          $document = JFactory::getDocument();
          $document-&gt;addScriptDeclaration($script);
          
          return $filterList;
  </code></pre>