Details

Description

I need to set the same margin-bottom to the TextFiled and its label, but when I call the method setStyle("margin-bottom", "20px") of the TextField, it does not set the same margin/style to its label; for the java code:
TextField cld = new TextField("cld", "My Text Field: ");
cld.setSize(20);
cld.setRequired(false);
cld.setStyle("margin-bottom", "20px");
form.add(cld);

Bob Schellink
added a comment - 12/Nov/09 08:58 This is not a bug. The Label is set by the Form and does not apply the Field styles to the label.
If you need fine grain control you can style the field and label using CSS selectors or if that doesn't work, use manual layout or a custom Form.

Styling margin is something usual and would be nice that the label associated to a field inherit that settings.
I think that would be useful if the field itself can set the style of its label with a method like setLabelStyle as the one of the form.
Thinking that all the label in the form must have the same style (form.setLabelStyle()) is a questionable choice, not convenient for web programming.
I like click framework and I find it very easy to use, so I hope that we can find a solution convenient for the users and the developers.

Stefax
added a comment - 12/Nov/09 10:03 Styling margin is something usual and would be nice that the label associated to a field inherit that settings.
I think that would be useful if the field itself can set the style of its label with a method like setLabelStyle as the one of the form.
Thinking that all the label in the form must have the same style (form.setLabelStyle()) is a questionable choice, not convenient for web programming.
I like click framework and I find it very easy to use, so I hope that we can find a solution convenient for the users and the developers.

I just attempted an implementation as discussed above, but it doesn't give the desired effect, especially when using margins. Applying the margin to the Field and Label still leaves the Label floating off-center.

Where do you expect the Field's labelStyle to be rendered. On the label element or the surround table cell?

Bob Schellink
added a comment - 07/Mar/10 03:11 Hi Stefax
I just attempted an implementation as discussed above, but it doesn't give the desired effect, especially when using margins. Applying the margin to the Field and Label still leaves the Label floating off-center.
Where do you expect the Field's labelStyle to be rendered. On the label element or the surround table cell?
kind regards
bob

It might be worth exposing Field methods getParentStlyeClass and getParentStyle that can be applied by parent containers such as Form/Fieldset. The getParentXXX methods are really just hints, since its up to the parent container how and if it will be applied.

For example Form could add the parentStyle to both the Label and Field cells:

Bob Schellink
added a comment - 07/Mar/10 05:53 It might be worth exposing Field methods getParentStlyeClass and getParentStyle that can be applied by parent containers such as Form/Fieldset. The getParentXXX methods are really just hints, since its up to the parent container how and if it will be applied.
For example Form could add the parentStyle to both the Label and Field cells:
this statement:
field.setParentStyle("padding-bottom:20px");
could render:
<td style='padding-bottom:20px">LABEL</td> <td style="padding-bottom:20px">FIELD</td>

Bob Schellink
added a comment - 14/Mar/10 02:30 Added new Field methods added for controlling the label style and style class.
Also added new methods for providing style and class hints to a parent container such as Form and FieldSet