Code Monkey home page Code Monkey logo

Comments (9)

Anahkiasen avatar Anahkiasen commented on May 30, 2024

Well this would be doable by fine tuning the checkboxes but since you might want a cleaner syntax I just pushed a little update to Former.
You can now do this to get your above example :

Former::checkboxes('value[]')->checkboxes('Value 01', 'Value 02')
Former::checkboxes('value')->grouped()->checkboxes('Value 01', 'Value 02') // Alternative syntax

Former recognizes the [] in the field and don't append iterators to the field's names.

from former.

kapooostin avatar kapooostin commented on May 30, 2024

Yes, it works, but only if I have a simple list of values. And it sends an indexed array of 1.

I enabled push_checkboxes, to get the whole list without holes, but still I'd prefer to assign meaningful values to every checkbox. And grouped() fails when I pass an associative array of name=>value pairs: name isn't values[] anymore.

from former.

kapooostin avatar kapooostin commented on May 30, 2024

Maybe I miss or mess something?

from former.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

Nope nope I think there is indeed a bug — or at least a lack of elegant syntax somewhere. I'm just kind of busy on the Laravel 4 branch for now but I'll use that opportunity to make checkables cleaner and more powerful.

from former.

Anahkiasen avatar Anahkiasen commented on May 30, 2024

On the composer branch I'm working on a new way to fine-tune checkable elements. In the past you had to create a complex array on either the checkboxes() or radios() methods.

Now you'll be able to temporarly focus on one of the checkable and all following chained methods will only apply to this one. So you can fine-tune like this :

Former::checkboxes('value')->grouped()
  ->checkboxes('First', 'Second')
  ->on(0)->value('new first checkbox value')->label('1st')
  ->on(1)->check()->addClass('second-checkbox')

It's still a work in progress but what do you think of the syntax ? Would that help with the more complex checkboxes fields you're trying to create ?

from former.

kapooostin avatar kapooostin commented on May 30, 2024

In my particular case I get all the data from the model, so I do no need to markup my form controls manually.

The syntax looks very flexible. I would definitely prefer it over a call of function with multiple arguments. Should we be concerned about debugging the long chained expressions? AFAIK, jQuery is considered to be hard to test because of similar syntax. What do you think?

And I still would like to be able to pass complex structured objects or arrays as an argument, or even json or yaml strings.

from former.

shayneoneill avatar shayneoneill commented on May 30, 2024

Can the group list be supplied as an array or query. That would be awesome (I have one awful array that needs to be checkboxes with about 90 values!!!!, yeah its an old design that I cant really negotiate down.)

from former.

claar avatar claar commented on May 30, 2024

I believe this issue can be closed?

from former.

kapooostin avatar kapooostin commented on May 30, 2024

I think it can

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.