Comments (11)
I think it has to do with the (complex) way Former has to check if a checkbox is checked (checking isn't it ?). I'll take a look at that.
from former.
Yeah, I started to peek at the code but got scared. :)
Btw, it works as expected if I pass ->value(1)
to the checkbox helper in my view.
- Colin
On 2012-10-22, at 4:16 PM, Maxime Fabre [email protected] wrote:
I think it has to do with the (complex) way Former has to check if a checkbox is checked (checking isn't it ?). I'll take a look at that.
—
Reply to this email directly or view it on GitHub.
from former.
You can disable the hidden fields with the push_checkboxes
option in your config file.
from former.
Yup, figured that out already! ;) The behaviour still exists, though.
- Colin
On 2012-10-22, at 5:50 PM, Maxime Fabre [email protected] wrote:
You can disable the hidden fields with the push_checkboxes option in your config file.
—
Reply to this email directly or view it on GitHub.
from former.
Ok I'm writing tests and having a hard time actually discerning what the issue is. Can you explain again your process here and what you wanted to do ?
from former.
Sure. The idea was to have a simple checkbox that toggled the value of an "active" attribute in a model. So, the only values are 0 and 1.
I imagine this to be the simplest case for checkboxes, and so would hope that the default behaviour of Former would make this the easiest to implement. In fact, I think it actually did work this way before the recent updates with push_checkboxes
etc..
So, in this case, I would like to simply populate Former with Former::populate( $model )
and then in my views do {{ Former::checkbox('active') }}
.
This should output the checkbox, with value=1
and the checked
state being dependent on whether $model->get_attribute('active')==1
.
from former.
If enabling push_checkboxes the text for the checkbox is no longer clickable. This doesn't seem like the correct behavior. Besides fixing that, I'd recommend making push_checkboxes off by default as it will go along with the standard form behavior and probably cause you less grief due to new users having problems.
from former.
Yeah i'll disable push checkboxes in next release, you're right.
from former.
cviebrock - If you set both: 'push_checkboxes' => true, 'unchecked_value' => '0' in the config file then it works as you have described. Checkbox will be unchecked if model = 0 and checked if model = 1.
from former.
@allmyitjason - yes, but doesn't that strike you as a lot of extra coding for (what I imagine is) the simplest scenario?
from former.
I disabled push checkbox by default in the meantime, still need to take a look at that scenario but all the tests I've written so far have passed so I'm kind of stuck.
from former.
Related Issues (20)
- Allow field->required() to receive a boolean HOT 1
- Allow field->inline() to receive a boolean HOT 2
- Add a Choice field type HOT 4
- Laravel 5.7 support HOT 1
- Support Bootstrap4 HOT 1
- Former Twitter Bootstrap 4 Not working HOT 2
- Custom Rule classes not working HOT 1
- Bootstrap 4 Framework uses wrong classes for input group & no classes for checkbox HOT 8
- Can Former be used outside/without Laravel? HOT 2
- Multiple attributes treated differently from single attribute in queryToArray
- Form echo like a text Laravel 5.7
- Encode checkbox value to prevent XSS attack HOT 1
- Bootstrap 4 throws error without open and close tag HOT 2
- How to style checkboxes HOT 6
- Laravel 8 support. HOT 1
- How to use vuejs directives with former HOT 2
- Former::date help HOT 1
- _method HOT 2
- How to use as a standalone PHP HOT 3
- Doesn't work on PHP8+ for standalone (non-laravel) apps HOT 1
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 former.