Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved input/dropdown view to allow selection of multiple values #173

Closed
wants to merge 1 commit into from

Conversation

adayth
Copy link
Contributor

@adayth adayth commented Mar 8, 2012

I needed this feature while developing a plugin so I think that should be useful to share this with the community.

The main change is that an array can be used in $vars['value'] to allow to select more of one value in dropdown box.
To detect the values in_array function is used.

With this change you can use code like this to output a multiple selection dropdown box:

$options = array(
    'name' => 'annotations[]',
    'options_values' => array('a'=>'a', 'b'='b', 'c'='c'),
    'value' => array('a', 'c'), // single value can be used too, e.g. 'a'
    'multiple' => true,
);
echo elgg_view('input/dropdown', $options);

Notes:

  • You need to use at the end of dropwdown's name [] so the form sends an array of values instead of only one.
  • You need to specify 'multiple' => true so format_attributes translates it in multiple="multiple" attribute in select form element.

I'm waiting your comments about this feature ;)

@ewinslow
Copy link
Contributor

Hmm... I don't think we can accept this for 1.8, actually. Can you open something against master?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants