Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
set fieldset select option selected
  • how can we set an <option> in fuelphp Fieldset <select> to be selected?
    or at least replace that field with manually created html?
  • HarroHarro
    Accepted Answer
    How do you create the fieldset? Manually? Or from an ORM model?

    In general, it uses the current value of the fieldset field as the selected option in case of a dropdown.
  • HarroHarro
    Accepted Answer
    A snippet from one of our apps (manually created fieldset):

    $options = \DB::select('id', array(\DB::expr('CONCAT(surname,", ",initials," ",prefix)'), 'name'))
        ->from('people')
        ->where('client_id', '=', $client_id)
        ->order_by('name', 'ASC')
        ->execute()
        ->as_array('id', 'name');

    $fieldset->field('contact_id')
        ->set_options($options)
        ->set_value($contact_id);

  • >> In general, it uses the current value of the fieldset field as the selected option in case of a dropdown.
    >> ->set_value($contact_id);

    awesome, exactly what i was looking for, thank you!

Howdy, Stranger!

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

In this Discussion