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

Option to render checkbox outside of label #106

Open
enumag opened this issue Jan 22, 2016 · 16 comments
Open

Option to render checkbox outside of label #106

enumag opened this issue Jan 22, 2016 · 16 comments

Comments

@enumag
Copy link
Contributor

enumag commented Jan 22, 2016

I'd like to be able to render checkbox (and radio) outside of the label tag. Without using manual rendering of course.

The reason is that I'd like to use awesome-bootstrap-checkbox to make them look better without using javascript.

@landsman
Copy link

Yes!

@dg
Copy link
Member

dg commented Apr 1, 2016

Can you try to figure out any solution?

@landsman
Copy link

landsman commented May 31, 2016

I am thinking about this again :(
What something like:

$form->addCheckbox("terms", "consultation.reserve.terms")->setHTML(...);

This is our problem:
https://api.nette.org/2.4.0/source-Forms.Controls.Checkbox.php.html#65

@enumag
Copy link
Contributor Author

enumag commented Jun 22, 2016

As you know I don't use nette/forms anymore... Currently I don't have a need nor time to solve this.

@enumag enumag closed this as completed Jun 22, 2016
@enumag enumag reopened this Jun 22, 2016
@enumag
Copy link
Contributor Author

enumag commented Jun 22, 2016

Closed by accident... it should probably be left open in my opinion.

@dg dg added this to the v2.5 milestone Jun 30, 2016
@Olicek
Copy link

Olicek commented Nov 15, 2016

It can be handled in custom renderer. In renderLabel and renderControl methods check if $control is instance of Checkbox. If it's, there can be called getLabelPart or getControlPart insted of getControl.

Don't know if it's good enought solution.

But there is problem with radioList. Problem is here. If i would be able to switch those 2 lines, it would be good enought. What about 5. parameter for createInputList method, witch would be bool and swith those lines. This parameter would be settable in RadioList and CheckboxList

@enumag
Copy link
Contributor Author

enumag commented Mar 19, 2017

@Olicek Can you post the code for renderer? I need this on one of my older projects, fortunately only for single checkboxes, no lists. Also your link to the source doesn't work correctly anymore. You should lock it to one commit.

@Olicek
Copy link

Olicek commented Mar 21, 2017

@enumag I fixed my previous link (thanks for alert). My rendere is on gist. Is it enaught for you? Would you like to have something else?

@enumag
Copy link
Contributor Author

enumag commented Mar 21, 2017

@Olicek Actually I already solved it myself but thanks anyway. ;-)

@dg dg modified the milestones: v3.0, v2.5 Jun 21, 2017
@dg dg modified the milestones: v3.0, v3.1 Apr 20, 2020
@dg dg removed this from the v3.1 milestone Jan 19, 2021
@dakur
Copy link

dakur commented Jun 21, 2021

I suggest to:

  • render <input> before <label> by default – basically to swap these two lines
  • to add id and for attributes for explicitly coupling of <input> and <label>

The problem is that now you can't render checkbox list which is compatible with Bootstrap v5 (or v4 custom control) markup as Bootstrap requires that label follows input. But it's not bootstrap-specific problem.

@dg Do you see any problem or BC break in making proposed changes? I can think only of broken styling if it depends on generated selectors and DOM structure:

form label input[type=checkbox] {
    border: 5px solid red;
}

@dg
Copy link
Member

dg commented Jun 21, 2021

When you change the generated HTML, it is of course a BC break.

@dakur
Copy link

dakur commented Jun 21, 2021

Ok, so what do you suggest then? There should be some way how to affect generated code, if we can not afford to change it.

@dg
Copy link
Member

dg commented Jun 21, 2021

Just add a method to toggle generated code, right?

@dakur
Copy link

dakur commented Jun 21, 2021

I don't understand. Generated code is of type string so what method do you think of that will be able to change it?

@dg
Copy link
Member

dg commented Jun 21, 2021

$form->addCheckbox('xxx')
	->renderLabelSeparately();

@dakur
Copy link

dakur commented Jun 22, 2021

Ok, why not, as basic solution that should be enough. 👍

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

No branches or pull requests

5 participants