Comments (16)
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
from forms.
$form->addCheckbox('xxx')
->renderLabelSeparately();
from forms.
Yes!
from forms.
Can you try to figure out any solution?
from forms.
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
from forms.
As you know I don't use nette/forms anymore... Currently I don't have a need nor time to solve this.
from forms.
Closed by accident... it should probably be left open in my opinion.
from forms.
@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.
from forms.
@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?
from forms.
@Olicek Actually I already solved it myself but thanks anyway. ;-)
from forms.
I suggest to:
- render
<input>
before<label>
by default – basically to swap these two lines - to add
id
andfor
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;
}
from forms.
When you change the generated HTML, it is of course a BC break.
from forms.
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.
from forms.
Just add a method to toggle generated code, right?
from forms.
I don't understand. Generated code is of type string
so what method do you think of that will be able to change it?
from forms.
Ok, why not, as basic solution that should be enough. 👍
from forms.
Related Issues (20)
- SubmitButton without caption throws depracated error on render on PHP 8.1
- UploadControl MaxLenght message %i HOT 1
- private const Array (request to change to public)
- Validation problem with rule MIME_TYPE
- Unable to add class to input programatically when rendered using n:name
- netteForms.js doesn't toggle properly when form is reset
- Cannot call method startTag() / endTag() on string
- addDate(), addTime(), addDateTime() - how to get nullable values?
- netteForms: min/max wrong validation of numbers HOT 1
- setValue() as well as setDefaultValue() don't set the value and the field shows error states instead HOT 2
- ChoiceControl::getRawValue(): Return value must be of type string|int, null returned HOT 1
- Validation of MimeType rule fails when FileControl->getContentType returns null HOT 1
- src/assets/netteForms.js broken in 3.2-dev HOT 1
- `Nette\Forms\Blueprint::dataClass($form)`: Undefined variable `$bp` HOT 1
- Number inputs format shouldn't be always validated HOT 7
- Number input with maxlength validation always fails HOT 2
- Compound condition does not toggle element
- Error in JS validation for rule Form::Image
- Implementation of setOmitted() to Nette\Forms\Rules
- errors cummulate when instances of Nette\HtmlStringable
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from forms.