Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Fuelphp equivalent of CI's form_dropdown()
  • I know the HTML class has many methods but I could not find the equivalent to form_dropdown() in CI which should create a dropdown menu (<select></<select>)
    any ideas?
    thank you ps: anyone knows how to get rid of these silly smileys?
  • echo Form::select('country', 'none', array(
    'none' => 'None',
    'europe' => array(
    'uk' => 'United Kingdom',
    'nl' => 'Netherlands'
    ),
    'us' => 'United States'
    )); i know how to do this but what i don't know is how to retrieve data from database through this method.. can anyone help me pls...
  • You don't, it's a form method, not a database access method. You will have to create a method in your model that returns the array that has to be used as input for the form::select() method.
  • Marlon Asis wrote on Thursday 20th of October 2011:
    echo Form::select('country', 'none', array(
    'none' => 'None',
    'europe' => array(
    'uk' => 'United Kingdom',
    'nl' => 'Netherlands'
    ),
    'us' => 'United States'
    )); i know how to do this but what i don't know is how to retrieve data from database through this method.. can anyone help me pls...
    what you need is $result = DB::select()->from('table')->where('')->execute()->as_array();
    you can find all the documentation you need under the DB class in the docs : http://fuelphp.com/docs/
  • thanks a lot guys!!! it works... now i can continue.
  • Hello, if you table county has for example:
    id, name, whatever, you can do smth like this; DB::select('id', 'name')
    ->from('countries')
    ->execute()->as_array('id', 'name'); And you'll get an array like:
    array (
    1 => US
    2 => UK
    );
    
    etc
  • As in CI, have a look to the Form class.
    echo Form::select('country', 'none', array(
        'none' => 'None',
        'europe' => array(
            'uk' => 'United Kingdom',
            'nl' => 'Netherlands'
        ),
        'us' => 'United States'
    ));
    

    Best regards.
  • Thank you very much !!
    sometimes it is easy to miss the obvious things!

Howdy, Stranger!

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

In this Discussion