Discussion:
[jifty-devel] Multiple-choice with checkbox
Stanislav Sinyagin
2009-09-04 14:40:19 UTC
Permalink
hi,

there seems to be the only option to have a multiple-choice list by using a
render_as => 'Select',
multiple => 1,


which is not very convenient for lists longer than 10 items.

It would be cool to have same thing as is done for Radio, but using checkboxes instead.

It's basically a clone of Jifty::Web::Form::Field::Radio with some minor modifications.
I can try submitting a patch, let's just invent a good name for it.

CheckboxMulti or MultipleChoice or MultiCheckbox ?



regards,
stan
Ruslan Zakirov
2009-09-04 15:15:54 UTC
Permalink
Hello Stanislav,

You can just use multiple argument in ::Radio and render them as
checkboxes :) It's wierd but will be consistent with Select.

Radio and multiple => 1 is confusing and instead of resolving
confusion it's better to create:

::Form::Choice with the following properties: look => {Dropdown,
List}, multiple => {0, 1}, alternative => {0, 1}.

This widget can delegate to particular implementation depending on properties:

Dropdown => Select
Dropdown, alternative => Combobox
List => Radios
List, multiple => Checkboxes
...

As you can see it requires more work, but you can implement only what
you need and live some combinations not implemented. For example
radios with alternative may look like this:

[x] default
[ ] some value
[ ] ____ text input for another value ____

"look", "Dropdown", "List" and other new terms are discussable.

PS: May be ::Checkbox is good choice instead of ::Radio with multiple
property, delegator can just pick correct class depending on props.
Post by Stanislav Sinyagin
hi,
there seems to be the only option to have a multiple-choice list by using a
render_as => 'Select',
multiple => 1,
which is not very convenient for lists longer than 10 items.
It would be cool to have same thing as is done for Radio, but using checkboxes instead.
It's basically a clone of Jifty::Web::Form::Field::Radio with some minor modifications.
I can try submitting a patch, let's just invent a good name for it.
CheckboxMulti or MultipleChoice or MultiCheckbox ?
regards,
stan
_______________________________________________
jifty-devel mailing list
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
--
Best regards, Ruslan.
Stanislav Sinyagin
2009-09-04 15:52:09 UTC
Permalink
hi Ruslan,

I think your proposal is a bit orthogonal to what is implemented now. Each of
the Form::* classes implement some elementary form input, so I would prefer having
it the same way.

Also multiple checkboxes need a bit of different indentation, so that one could recongize a group.

Here's a first draft of the new module. I'm not sure yet the default_values work correctly:
http://pastebin.com/m599d2e1d

regards,
stanislav




----- Original Message ----
Post by Ruslan Zakirov
::Form::Choice with the following properties: look => {Dropdown,
List}, multiple => {0, 1}, alternative => {0, 1}.
Dropdown => Select
Dropdown, alternative => Combobox
List => Radios
List, multiple => Checkboxes
...
As you can see it requires more work, but you can implement only what
you need and live some combinations not implemented. For example
Ruslan Zakirov
2009-09-04 19:10:19 UTC
Permalink
Hello Stanislav,

May be I was not clear enough. I was not talking about multiple groups
of checkboxes, but only about a selector widget that allows user
select one or several values for an argument of the action. We can
render such selector widget in different ways, for example it can
<select>, set of radio buttons, set of checkboxes to allow user select
multiple values, it can be combobox to allow user type alternative
value, it can checkboxes with text input for alternative. For you as
developer there should be no difference between them, you picked
multi-select, but then decided that checkboxes are better and you just
switch renderer and code just works.

About your code:
* MultiChoice is bad name. You say that you prefer elementary
functionality then it should be named Checkbox. Checkbox is the way to
allow people choose multiple values, otherwise radio buttons should be
used.
* ::Radio, ::Select and other don't wrap widget into a div and you shouldn't too
* probably you shouldn't wrap each element into a div, but span

What I don't like is Zoo and hope you understand that it's more
pleasant to work with consistent and predictable enviroment.
Post by Stanislav Sinyagin
hi Ruslan,
I think your proposal is a bit orthogonal to what is implemented now. Each of
the Form::* classes implement some elementary form input, so I would prefer having
it the same way.
Also multiple checkboxes need a bit of different indentation, so that one could recongize a group.
http://pastebin.com/m599d2e1d
regards,
stanislav
----- Original Message ----
Post by Ruslan Zakirov
::Form::Choice with the following properties: look => {Dropdown,
List}, multiple => {0, 1}, alternative => {0, 1}.
Dropdown => Select
Dropdown, alternative => Combobox
List => Radios
List, multiple => Checkboxes
...
As you can see it requires more work, but you can implement only what
you need and live some combinations not implemented. For example
_______________________________________________
jifty-devel mailing list
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
--
Best regards, Ruslan.
Stanislav Sinyagin
2009-09-04 19:54:46 UTC
Permalink
hi Ruslan,

I see your point, but I can't find a better solution :)

Having one Form::Field subclass for all kinds of multiple-choice selection
looks attractive, but difficult to implement and make everyone happy.

In regards to div/span layout: the choices should be arranged one above the
other, otherwise it doesn't scale. In the application which I develop now,
I extract a number of data element names from an external database, and then
let the user choose all or some of them for further processing. The number can be
arbitrary, so they have to be arranged one on top of the other.

Probably I have to end up with a subclass of Action and override attributes()
so that it generates the needed number of checkboxes. However, then we don't
have a way to group them (I actually extract 4 different groups of data elements,
and was going to give the user four multiple-choice selections on one page).

any suggestions?







________________________________
From: Ruslan Zakirov <***@gmail.com>
To: Nifty apps in a Jiffy <jifty-***@lists.jifty.org>
Sent: Friday, September 4, 2009 9:10:19 PM
Subject: Re: [jifty-devel] Multiple-choice with checkbox

Hello Stanislav,

May be I was not clear enough. I was not talking about multiple groups
of checkboxes, but only about a selector widget that allows user
select one or several values for an argument of the action. We can
render such selector widget in different ways, for example it can
"select" set of radio buttons, set of checkboxes to allow user select
multiple values, it can be combobox to allow user type alternative
value, it can checkboxes with text input for alternative. For you as
developer there should be no difference between them, you picked
multi-select, but then decided that checkboxes are better and you just
switch renderer and code just works.

About your code:
* MultiChoice is bad name. You say that you prefer elementary
functionality then it should be named Checkbox. Checkbox is the way to
allow people choose multiple values, otherwise radio buttons should be
used.
* ::Radio, ::Select and other don't wrap widget into a div and you shouldn't too
* probably you shouldn't wrap each element into a div, but span

What I don't like is Zoo and hope you understand that it's more
pleasant to work with consistent and predictable enviroment.
Post by Stanislav Sinyagin
hi Ruslan,
I think your proposal is a bit orthogonal to what is implemented now. Each of
the Form::* classes implement some elementary form input, so I would prefer having
it the same way.
Also multiple checkboxes need a bit of different indentation, so that one could recongize a group.
http://pastebin.com/m599d2e1d
regards,
stanislav
----- Original Message ----
Post by Ruslan Zakirov
::Form::Choice with the following properties: look => {Dropdown,
List}, multiple => {0, 1}, alternative => {0, 1}.
Dropdown => Select
Dropdown, alternative => Combobox
List => Radios
List, multiple => Checkboxes
...
As you can see it requires more work, but you can implement only what
you need and live some combinations not implemented. For example
_______________________________________________
jifty-devel mailing list
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
--
Best regards, Ruslan.
Ruslan Zakirov
2009-09-04 21:06:19 UTC
Permalink
Post by Stanislav Sinyagin
hi Ruslan,
re

[snip]
Post by Stanislav Sinyagin
In regards to div/span layout: the choices should be arranged one above the
other, otherwise it doesn't scale. In the application which I develop now,
I extract a number of data element names from an external database, and then
let the user choose all or some of them for further processing. The number can be
arbitrary, so they have to be arranged one on top of the other.
http://stackoverflow.com/questions/65849/how-to-insert-line-breaks-in-html-documents-using-css
--
Best regards, Ruslan.
Ruslan Zakirov
2009-09-04 21:19:28 UTC
Permalink
Post by Ruslan Zakirov
Post by Stanislav Sinyagin
hi Ruslan,
re
[snip]
Post by Stanislav Sinyagin
In regards to div/span layout: the choices should be arranged one above the
other, otherwise it doesn't scale. In the application which I develop now,
I extract a number of data element names from an external database, and then
let the user choose all or some of them for further processing. The number can be
arbitrary, so they have to be arranged one on top of the other.
http://stackoverflow.com/questions/65849/how-to-insert-line-breaks-in-html-documents-using-css
I'm not the css guy and probably is not the best person to suggest,
but I do know that div is incorrect here. May be it's better to use
unsorted-list (<ul>) instead of wrapping everything into span as it's
really list of available options. Lists are pretty easy to css in
different ways and there a lot of information about that.
Post by Ruslan Zakirov
--
Best regards, Ruslan.
--
Best regards, Ruslan.
Stanislav Sinyagin
2009-09-04 22:14:01 UTC
Permalink
Ruslan,
Post by Ruslan Zakirov
Post by Stanislav Sinyagin
In regards to div/span layout: the choices should be arranged one above the
other, otherwise it doesn't scale. In the application which I develop now,
I extract a number of data element names from an external database, and then
let the user choose all or some of them for further processing. The number
can be
Post by Stanislav Sinyagin
arbitrary, so they have to be arranged one on top of the other.
http://stackoverflow.com/questions/65849/how-to-insert-line-breaks-in-html-documents-using-css
actually the only difference between div and span is the default value of "display"
property. DIV has by default display:block, and SPAN is display:inline.

There's no other difference between these two elements, so there's very little sense
in making a SPAN and then overriding its display type with CSS.

So, if it's thought to be vertically stacked, DIV is the right way to go.
It can easily be converted back to inline by app-specific CSS, if needed.

thus, for now I'm not convinced your proposal is better.

Changing the Field::Checkbox behavior, such that if the "multiple" property is set,
draw a group of checkboxes, seems reasonable. I can merge my "MultipleChoice" and the current
"Checkbox" into one module. Still, the open question is how to display the items.
I still think that placing each item in a DIV, and having an embracing DIV is the
right way to go.
Ruslan Zakirov
2009-09-04 21:11:59 UTC
Permalink
Post by Stanislav Sinyagin
hi Ruslan,
[snip]
Post by Stanislav Sinyagin
Probably I have to end up with a subclass of Action and override attributes()
so that it generates the needed number of checkboxes. However, then we don't
have a way to group them (I actually extract 4 different groups of data elements,
and was going to give the user four multiple-choice selections on one page).
any suggestions?
Probably I miss something, but I see this as four different arguments
of an action, each argument rendered as a ::Checkbox widget, where one
widget != one checkbox input field, but many with the same name and
you get values in the action as array.
--
Best regards, Ruslan.
Stanislav Sinyagin
2009-09-06 18:49:34 UTC
Permalink
I had a look at the current code once more, and I think it would be a wrong
idea to extend Jifty::Web::Form::Field::Checkbox so that it would display
multiple checkboxes if needed.

I would propose a separate class for multiple-choice.
What about "CheckboxGroup"?





________________________________
From: Ruslan Zakirov <***@gmail.com>
To: Nifty apps in a Jiffy <jifty-***@lists.jifty.org>
Sent: Friday, September 4, 2009 9:10:19 PM
Subject: Re: [jifty-devel] Multiple-choice with checkbox

Hello Stanislav,

May be I was not clear enough. I was not talking about multiple groups
of checkboxes, but only about a selector widget that allows user
select one or several values for an argument of the action. We can
render such selector widget in different ways, for example it can
"select", set of radio buttons, set of checkboxes to allow user select
multiple values, it can be combobox to allow user type alternative
value, it can checkboxes with text input for alternative. For you as
developer there should be no difference between them, you picked
multi-select, but then decided that checkboxes are better and you just
switch renderer and code just works.

About your code:
* MultiChoice is bad name. You say that you prefer elementary
functionality then it should be named Checkbox. Checkbox is the way to
allow people choose multiple values, otherwise radio buttons should be
used.
* ::Radio, ::Select and other don't wrap widget into a div and you shouldn't too
* probably you shouldn't wrap each element into a div, but span

What I don't like is Zoo and hope you understand that it's more
pleasant to work with consistent and predictable enviroment.
Post by Stanislav Sinyagin
hi Ruslan,
I think your proposal is a bit orthogonal to what is implemented now. Each of
the Form::* classes implement some elementary form input, so I would prefer having
it the same way.
Also multiple checkboxes need a bit of different indentation, so that one could recongize a group.
http://pastebin.com/m599d2e1d
regards,
stanislav
----- Original Message ----
Post by Ruslan Zakirov
::Form::Choice with the following properties: look => {Dropdown,
List}, multiple => {0, 1}, alternative => {0, 1}.
Dropdown => Select
Dropdown, alternative => Combobox
List => Radios
List, multiple => Checkboxes
...
As you can see it requires more work, but you can implement only what
you need and live some combinations not implemented. For example
_______________________________________________
jifty-devel mailing list
http://lists.jifty.org/cgi-bin/mailman/listinfo/jifty-devel
--
Best regards, Ruslan.
Stanislav Sinyagin
2009-09-07 15:18:59 UTC
Permalink
hi,

the following patch is committed:
http://pastebin.com/m5cccd4ee

tested good so far :)

Continue reading on narkive:
Loading...