We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Checkboxes

Development and Programming

Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

This extension is very similar to the “Multi Drop-down List” I created here http://ellislab.com/forums/viewthread/38370/, however instead of a list it gives you checkboxes. Let me know how this works for you all.

Update 1 Added the ability to use separator=”[string]” in a template tag to override the default separator

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Great!

Seems to work well.

I did notice that it stores the value of the checkbox, instead of a reference to it, like a Drop-down List does. This makes updating the values nearly impossible. (you’d have to re-save all entries with the new values)

Thanks

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

I’m not sure I understand. This, in my opinion, works the same way as the Drop-down list. Are you implying that the drop down list stores references? Can you explain a little bit more?

       
Cocoaholic's avatar
Cocoaholic
445 posts
18 years ago
Cocoaholic's avatar Cocoaholic

Oops,

Have been staring at my screen a bit longer than I should 😉

It does work the same as the Drop-down List! I was looking at the wrong data in exp_weblog_data.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Understood. That exp_weblog_data table can get quite unmanageable.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Update: i’ve added the ability to define a separator in a template tag now.

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
18 years ago
Dom Stubbs's avatar Dom Stubbs

Thanks for sharing this, it looks like exactly what I’m after. First impressions are that it works perfectly, but I did receive this error when I created a new checkbox-style custom field:

Notice: Undefined variable: field_type in /path/system/cp/cp.publish_ad.php on line 5402
       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Unfortunately, this is an inherent error in EE. It comes in the Edit Field Group page where there is a switch statement that defines the variable $field_type.

switch ($row['field_type'])
{
    case 'text' :  $field_type = $LANG->line('text_input');
        break;
    case 'textarea' :  $field_type = $LANG->line('textarea');
        break;
    case 'select' :  $field_type = $LANG->line('select_list');
        break;
    case 'date' :  $field_type = $LANG->line('date_field');
        break;
    case 'rel' :  $field_type = $LANG->line('relationship');
        break;
}

The problem with this is that below the switch they echo out $field_type, and if the field type is not in their switch then $field_type will not be defined.

If you would like to fix this problem I would recommend the following (and hopefully pMachine will follow suite).

Find the following line (around 5388):

switch ($row['field_type'])

before that place this line:

$field_type = "";

So that switch should look like this:

$field_type = "";
switch ($row['field_type'])
{
    case 'text' :  $field_type = $LANG->line('text_input');
        break;
    case 'textarea' :  $field_type = $LANG->line('textarea');
        break;
    case 'select' :  $field_type = $LANG->line('select_list');
        break;
    case 'date' :  $field_type = $LANG->line('date_field');
        break;
    case 'rel' :  $field_type = $LANG->line('relationship');
        break;
}

That should fix your PHP Notice.

       
Dom Stubbs's avatar
Dom Stubbs
156 posts
18 years ago
Dom Stubbs's avatar Dom Stubbs

That works a charm. Thanks Mark.

       
Ryan M.'s avatar
Ryan M.
1,511 posts
18 years ago
Ryan M.'s avatar Ryan M.

Nice, looking forward to trying this as well as the multi-select extension. Thanks for your work.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

If you’re using this extension in combination with any of my other extensions it is highly recommended that you update all of them or field data may not enter correctly. You can find links to the individual posts below:

Checkbox: http://ellislab.com/forums/viewthread/38843/ Multi Drop-down List: http://ellislab.com/forums/viewthread/38370/ Multi Text: http://ellislab.com/forums/viewthread/39153/ File: http://ellislab.com/forums/viewthread/38997/

Or you can find a list of them on my docs page: http://docs.markhuot.com

       
james Brown's avatar
james Brown
492 posts
18 years ago
james Brown's avatar james Brown

hey mark, is it possible to have the separator removed from the last item? Problem is, when out putting a list, you end up with something like this “Oranges, Apples, Watermellon,”. The last camma is not needed.

       
Mark Huot's avatar
Mark Huot
587 posts
18 years ago
Mark Huot's avatar Mark Huot

Hum, it shouldn’t do that. My guess is you have an extra blank space in your database. I’ll look into why that may be there (or why the extension is outputting incorrect separators). Thanks for the heads up!

       
David Webb's avatar
David Webb
62 posts
18 years ago
David Webb's avatar David Webb

Hey Mark, really like the idea of your extension but I’ve got a couple of requests.

1) Being able to select {title} as the field we wish to pre-populate from. and 2) is there a way to (for lack of a better word) separate the info back out when we parse it in the weblog entries tag?

       
james Brown's avatar
james Brown
492 posts
18 years ago
james Brown's avatar james Brown

couldn’t you just save the output of the tag to a php variable, then explode the variable to a php array?

       
1 2 3 Last

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.