We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    I am planning to implement ClassExtender very soon, but want to make sure I do it right the first time. Right now I am concerned about how to implement radio buttons and checkboxes, if possible.

    Previously I checked the form to create the custom db and found the sample for text strings:

    <field key="firstName" dbtype="varchar" precision="50" phptype="string" null="true"/>

    But now I need other types of data, I assume I have to change the sample code. Going through some related files on Bob's website, here: http://bobsguides.com/modx-object-full-reference.html, I find some interesting stuff.

    Maybe this is what I need.

        [dbtype] => int
        [precision] => 10
        [attributes] => unsigned
        [phptype] => integer
        [default] => 0


    This also opens up the question of do I need the [attributes].

    I also found this:

                [dbtype] => tinyint
                [precision] => 1
                [phptype] => boolean
                [attributes] => unsigned
                [default] => 1



    So these two would seem to solve the problem, the boolean is for radio buttons, and the integer can be used for checkboxes, or should I just use boolean for both...I guess boolean for both makes more sense, I am just asking users if they are interested in any of the following: movies, music, apples, space and whether they are in X group or Y group.

    I guess integer would be suitable for age or years of experience.

    I do want to get some confirmation before I experiment with this. Thanks!

    This question has been answered by BobRay. See the first response.

    • discuss.answer
      • 3749
      • 24,544 Posts
      Your conclusions look right to me. Boolean for anything that can be expressed as 0/1 and integer for stuff that will have other integer values. Of course PHP isn't all that picky, so you could actually use varchar for everythings, but you'd waste a little space in the DB.
        Did I help you? Buy me a beer
        Get my Book: MODX:The Official Guide
        MODX info for everyone: http://bobsguides.com/modx.html
        My MODX Extras
        Bob's Guides is now hosted at A2 MODX Hosting
        • 46886
        • 1,154 Posts
        Ok thanks I will provide feedback when I try it out. I think I will just use boolean for all of them, it just seems easier.