Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fieldset Form SELECT / OPTION
  • How can i add a SELECT dropdown with the FIELDSET Class?
  • $options = array(
        'key1' => 'value1',
        'key2' => 'value2',
    );
    
    \Fieldset::instance('name')->add(
        'name',
        'Label',
        array(
            'type' => 'select',
            'options' => $options,
            'value' => 'selected_values_array_key'
        ),
        array(
            array('required'),
        )
    );
    
  • Awesome! how do we do OPTGROUPS. If you follow the same theory of the FORM class it doesn't work in the FIELDSET class.
  • Make the options array go two levels. It'll put the top level as groups.
  • It's not working.... I tried the follwoing: $options = array("group1"=>array("key1"=>"value 1", "key2"=>"value 2"));
    $article_form->add('categories', 'Categories', array('type' => 'select', 'options' => $options, 'value' => '', 'class' => 'pretty_input'));
  • Checkout the form class in the docs. The select method actually does the work for the fieldset add-select.
  • I did. This might be a bug then. I did the following, like the Form::select docs example: $options = array('none' => 'None', 'europe' => array('uk' => 'United Kingdom', 'nl' => 'Netherlands'), 'us' => 'United States');
    $article_form->add('countries', 'Country', array('type' => 'select', 'options' => $options, 'value' => '', 'class' => 'pretty_input')); ... and the result was a select with options:
    none = None
    europe = Array
    us = United States

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion