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

Multi-select field #737

Closed
rafahoro opened this issue Jun 1, 2020 · 1 comment · Fixed by #824
Closed

Multi-select field #737

rafahoro opened this issue Jun 1, 2020 · 1 comment · Fixed by #824
Assignees
Labels
Type: Feature New features and feature requests
Milestone

Comments

@rafahoro
Copy link

rafahoro commented Jun 1, 2020

Hi
First all: Kudos and Thank you for the vazco/uniforms package. Im using it for first time in a project and I found it really helpful.

I was trying to get a combo-box for selecting multiple items, but I was only able to get a list of checkboxes (or radios). As the length of my allowed-values is more than 20, having a list of checkboxes makes the form not so appealing.
I found this issue #34 but still not sure why Uniforms doesn't provide a MultiSelect combobox.

Even more, based on https://github.com/vazco/uniforms/blob/944645fe6d2929e195238e910d2d29fc64ca3083/packages/uniforms-bootstrap4/src/SelectField.tsx
I have modified the renderSelect to be


const renderSelect = props => (
  <select
    className={classnames(props.inputClassName, 'c-select form-control', {
      'is-invalid': props.error,
    })}
    disabled={props.disabled}
    id={props.id}
    name={props.name}
    multiple={props.fieldType === Array}
    onChange={event => {
      const item = event.target.value;
      props.onChange(
        props.fieldType === Array ? xor(item, props.value) : item,
      );
    }}
    ref={props.inputRef}
    value={props.value}
  >
    {(!!props.placeholder || !props.required || props.value === '') && (
      <option value="" disabled={props.required} hidden={props.required}>
        {props.placeholder || props.label}
      </option>
    )}

    {props.allowedValues.map(value => (
      <option key={value} value={value}>
        {props.transform ? props.transform(value) : value}
      </option>
    ))}
  </select>
);

const Select = props =>
  wrapField(
    props,
    renderSelect(props),
  );

and I've got a working multi-select combo-box on my project.

So, basically my question is: why doesn't Uniforms provide such multiple-select out of the box (at least for bootstrap)?

@radekmie radekmie self-assigned this Jun 3, 2020
@radekmie radekmie added the Type: Feature New features and feature requests label Jun 3, 2020
@radekmie radekmie added this to the v3 milestone Jun 3, 2020
@radekmie
Copy link
Contributor

radekmie commented Jun 3, 2020

Hi @rafahoro. Well, #34 was quite some time ago (almost 4 years). My opinion remains more or less the same - we won't include 3rd party plugins for fields nor fields for a limited set of themes only. But as I see, your proposal is to use multiple, a standard HTML option. In this case, all themes could use that (as a fallback if something better exists, like in AntD and Material-UI). We'll plan that right after v3 release.

@radekmie radekmie modified the milestones: v3.0, v3.x Jun 6, 2020
@radekmie radekmie assigned kestarumper and unassigned radekmie Aug 19, 2020
@radekmie radekmie assigned Monteth and unassigned kestarumper Oct 9, 2020
@radekmie radekmie modified the milestones: v3.x, v3.1 Dec 21, 2020
@radekmie radekmie linked a pull request Dec 21, 2020 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Type: Feature New features and feature requests
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

4 participants