Comments (9)
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.
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.
Maybe I miss or mess something?
from former.
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.
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.
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.
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.
I believe this issue can be closed?
from former.
I think it can
from former.
Related Issues (20)
- Add method to create new field from string HOT 7
- 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
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.