Love Fuel?
Donate
About
Forums
Discussions
Login
FuelPHP Forums
Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
General
How do I add a "select" input type to a form?
JeanAlesi
August 2015
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...?
Harro
August 2015
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.
Add a Comment
Howdy, Stranger!
It looks like you're new here. If you want to get involved, click one of these buttons!
Sign In
Apply for Membership
Categories
All Discussions
5,089
General
↳ General
3,364
↳ Job Board
13
↳ Installation & Setup
214
Packages
↳ Oil
213
↳ Orm
700
↳ Auth
261
Development
↳ Tips and Tutorials
126
↳ Code share
145
↳ Applications
52
In this Discussion
Harro
August 2015