Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
How do I add a "select" input type to a form?
  • I am enabling a search box, which should search for different things depending on the value of the select box.. So far, my form has these elements:

    class FriendSearchForm extends BaseHorizontalForm {
    public function __construct($tmuser) {
    // create the registration fieldset
    $form = \Fieldset::forge('form', array(
    'error_class' => 'error',
    'field_template' => $this->field_template,
    'form_template' => '{fields}',
    ));

    $form->add(
    'search', 'Search',
    array('type' => 'text', 'class' => 'form-control', 'value' => 'Search')
    )
    ->add_rule('trim')
    ->add_rule('required');
                    $form->add(
                                'submit', 'Submit', array('type' => 'submit', 'class' => 'btn btn-info', 'value' => 'submit')
                    );



    How would I add a select box so that the user can decide whether he wants to search for other users based on id, username, or other...?
  • HarroHarro
    Accepted Answer
    You set the type to "select" instead of "text".

    And you can use ->set_options() to define the option list for the dropdown.

Howdy, Stranger!

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

In this Discussion