Code Monkey home page Code Monkey logo

Comments (11)

Anahkiasen avatar Anahkiasen commented on May 30, 2024

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.

cviebrock avatar cviebrock commented on May 30, 2024

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.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

You can disable the hidden fields with the push_checkboxes option in your config file.

from former.

cviebrock avatar cviebrock commented on May 30, 2024

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.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

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.

cviebrock avatar cviebrock commented on May 30, 2024

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.

TommyC81 avatar TommyC81 commented on May 30, 2024

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.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

Yeah i'll disable push checkboxes in next release, you're right.

from former.

allmyitjason avatar allmyitjason commented on May 30, 2024

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.

cviebrock avatar cviebrock commented on May 30, 2024

@allmyitjason - yes, but doesn't that strike you as a lot of extra coding for (what I imagine is) the simplest scenario?

from former.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.