Giter Site home page Giter Site logo

multicheckbox label about cgmconfigadmin HOT 6 OPEN

cgmartin avatar cgmartin commented on May 17, 2024
multicheckbox label

from cgmconfigadmin.

Comments (6)

cgmartin avatar cgmartin commented on May 17, 2024

I think you can supply value_options with an assoc array (key => value, value => label). Internally I believe it calls setValueOptions(): http://framework.zend.com/manual/current/en/modules/zend.form.element.multicheckbox.html

i.e.:

'multiCheckboxOption' => array(
    'input_type'    => 'multicheckbox',
    'label'         => 'MultiCheckbox Option',
    //'value_options' => array('Foo', 'Bar', 'Dev', 'Null'), // value and label are the same
    'value_options' => array('foo' => 'Foo Label', 'bar' => 'Bar Label'), // value and label are different
    'default_value' => array('foo'),
),

from cgmconfigadmin.

Perfect-Web avatar Perfect-Web commented on May 17, 2024

@cgmartin i tried, doesnt work, also if you have multiple values selected, it only returns 1 value, not all the selected values

from cgmconfigadmin.

cgmartin avatar cgmartin commented on May 17, 2024

I can't replicate this behavior, it works for me with ZF 2.1.4 and 2.3.7. Here is the config I used:
https://gist.github.com/cgmartin/02a939557c9517a8830e#file-cgnconfigadmin-global-php-L61

And the getConfigValue which returns multiple selected values:
https://gist.github.com/cgmartin/02a939557c9517a8830e#file-indexcontroller-php

array(4) {
  [0] => string(3) "foo"
  [1] => string(3) "bar"
  [2] => string(3) "dev"
  [3] => string(4) "null"
}

from cgmconfigadmin.

Perfect-Web avatar Perfect-Web commented on May 17, 2024

sorry about that, was a false alarm, turned out the config was cached :( ....

from cgmconfigadmin.

Perfect-Web avatar Perfect-Web commented on May 17, 2024

@cgmartin i just realized it works only if you have as key a non-numeric string, basically i cant make this work because i need the values to be integers and not strings. is all related to this function

protected function isAssocArray($arr)
    {
        return (bool)count(array_filter(array_keys($arr), 'is_string'));
    }

from cgmconfigadmin.

cgmartin avatar cgmartin commented on May 17, 2024

IIRC, by default, the input elements operate off of string type values for the options (since that is what they are ultimately rendered and received as via the web page as HTML). There are "filters", that can be used to convert the data, but I doubt they are supported in this project. PRs are welcome, but as a workaround you might consider converting to int manually when retrieving.

from cgmconfigadmin.

Related Issues (12)

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.