Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
Help with fill form::select from ORM
  • Hi,
    Is there an easier way to fill a selectbox from orm rather than using a foreach?

    Thanks
  • Use Arr::pluck():

    // get all user records
    $collection = Model_Users::get();

    // extract an assoc array with id -> name
    // result: array(2 => 'Bill', 5 => 'Chris', 7 => 'Bert');
    $names = \Arr::pluck($collection, 'name', 'id');

  • Thanks Harro...

Howdy, Stranger!

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

In this Discussion