Form icon indicating copy to clipboard operation
Form copied to clipboard

Add Multiple Selection, Or Check Boxes

Open chassrouny opened this issue 9 years ago • 26 comments

Please add a control like check boxes, or a dropdown menu with multiple selection.

chassrouny avatar Mar 12 '15 10:03 chassrouny

@charbelhass thanks! We'll look into it.

3lvis avatar Mar 12 '15 10:03 3lvis

I have implemented this before, I might take a look if/when I get some time guys :+1:

callumboddy avatar Mar 12 '15 10:03 callumboddy

thank you :D

chassrouny avatar Mar 12 '15 10:03 chassrouny

:cake:

zenangst avatar Mar 12 '15 11:03 zenangst

any chance someone can do this? :)

danr777 avatar Mar 31 '15 10:03 danr777

@danr777 Hi danr777! Mind giving us a use case to start brainstorming on the best way to do this?

3lvis avatar Mar 31 '15 10:03 3lvis

Hi there, Could be anything really?Could be as simple as What are your favorite categories of foods? storing the answer value as a delimited string wouldn't be wrong would it? and splitting it upon value retrieval, is there a structural issue with storing the value that would be different than most of the other answer types?

danr777 avatar Mar 31 '15 10:03 danr777

@danr777 That's a great idea! I'll look into it

Our biggest issue at the moment is that a FORMField stores only one value

https://github.com/hyperoslo/Form/blob/master/Source/Models/FORMField.h#L27

3lvis avatar Mar 31 '15 10:03 3lvis

json representation could be something like this:

{
            "id":"foods",
            "title":"Favourite Foods",
            "type":"radio",
            "options": [
                 {
                 "id" : "uid"
                  "value" : "ice-cream"
                 },
                 etc..
           ] 
}

populate the radioField subclass from the options array, which dynamically creates the boxes.

you can then store a sub-array of checked boxes against the FORMField anyway as it is of type id anyway,

callumboddy avatar Mar 31 '15 11:03 callumboddy

Any news about this one. Thanks in advance

chassrouny avatar Apr 08 '15 12:04 chassrouny

Hello again @3lvis can we have the multiselect on master branch

chassrouny avatar Apr 17 '15 10:04 chassrouny

This is how it should look

multiselect

3lvis avatar Apr 27 '15 18:04 3lvis

Can this be limited to one selection? To make it act like a radio button?

jeffleeismyhero avatar Apr 27 '15 20:04 jeffleeismyhero

The JSON for the field could look like this,

{
  "id": "skill_types",
  "title": "Has the patient had or presently have any of the following conditions?",
  "type": "multiselect",
  "min_selected_values": 1,
  "max_selected_values": 3,
  "values": [
    {
      "id": 0,
      "title": "Hearth Attack"
    },
    {
      "id": 1,
      "title": "Stroke"
    },
    {
      "id": 2,
      "title": "Ulcer"
    },
    {
      "id": 3,
      "title": "Chest pains"
    },
    {
      "id": 4,
      "title": "Hypertension"
    },
    {
      "id": 5,
      "title": "Cancer"
    },
    {
      "id": 6,
      "title": "Fainting"
    },
    {
      "id": 7,
      "title": "High Colesterol"
    },
    {
      "id": 8,
      "title": "Osteoporosis"
    }
  ]
}

3lvis avatar Apr 27 '15 21:04 3lvis

No progress coming soon; feel free to send a PR following the suggested design. :)

3lvis avatar Apr 28 '15 06:04 3lvis

@3lvis I really like the design here, do you have anything else to go off of if one of us wants to start a PR?

jeffreyjackson avatar Jun 12 '15 17:06 jeffreyjackson

Please! my previous attempt was not up to par :)

On Fri, Jun 12, 2015 at 1:11 PM Jeffrey Jackson [email protected] wrote:

@3lvis https://github.com/3lvis I really like the design here, do you have anything else to go off of if one of us wants to start a PR?

— Reply to this email directly or view it on GitHub https://github.com/hyperoslo/Form/issues/242#issuecomment-111560541.

danr777 avatar Jun 12 '15 22:06 danr777

@jeffreyjackson feel free to start a PR, let me know if I can help with anything :)

3lvis avatar Jun 18 '15 14:06 3lvis

@3lvis I really like the design of the multiselect here, but I also think that it also makes sense to consider a solution similar to the current select method now. The difference would be that the rows are annotated with checkmarks for those that are selected. Therefore you would be able to select multi items in the tableView. The form field would then be delimited by commas. For a client project Im on now, hyperoslo/form has a lot of potential. The concern is that while the proposed multiselect looks great and would be awesome from a UX perspective, it would not be ideal in a scenario where there are potentially tens/hundreds of options to select from. What are your thoughts?

I'd like to consider the possibility of being to implement both, but obviously would like your consideration on this.

jeffreyjackson avatar Jun 18 '15 15:06 jeffreyjackson

I see how the comma separated list would work and would be easier/faster to implement, but it feels like a halfway solution. And there are other caveats too, like you wouldn't be able to support field titles with commas, or you would have to make a field that is super long in order to show the selected results.

Personally I would prefer if we had the proposed UI, I understand that it's harder to implement but it just feels right.

3lvis avatar Jun 18 '15 16:06 3lvis

First, let me ask you this:
Would it be difficult to dynamically resize the form field for large inputs instead of truncated with a ...? Or does it have this functionality somehow now?

jeffreyjackson avatar Jun 18 '15 17:06 jeffreyjackson

@jeffreyjackson Changing the width of the field then invalidating the layout should work.

The width of the cell depends on the width of the field. You can find the implementation here.

https://github.com/hyperoslo/Form/blob/eed1f04d63dbecf0e4a62993f4f7150a20847fdd/Source/FORMDataSource.m#L286

3lvis avatar Jun 18 '15 18:06 3lvis

@3lvis I was thinking that the height would resize to show all content?

jeffreyjackson avatar Jun 18 '15 19:06 jeffreyjackson

Is there any chance of implementing this still?

aminiz avatar May 01 '17 22:05 aminiz

@aminiz maybe any of the contributors or you might help with this, personally, I don't think I will have the chance to add this feature. If you need support working on this, hit me up on https://gitter.im/hyperoslo/Form

3lvis avatar May 02 '17 04:05 3lvis

refer to pr #594 already add this feature, hope this help

chy89310 avatar Apr 03 '19 02:04 chy89310