• Resolved webmoxie

    (@webmoxie)


    I have a database list with several fields controlled by checkboxes. I’m using css to replace the outputted text with an image. However, I’d like for an unchecked checkbox to return NO image. To do so, I think the easiest way is to use :empty in the css, but the unchecked fields are not outputted as empty, but with some blank space. How can I delete this extra space so that the <td> will be empty? I’ve been looking at the FormElement.class.php file but I’m confused about the hidden field. Suggestions?

    http://wordpress.org/extend/plugins/participants-database/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author xnau webdesign

    (@xnau)

    To really control this, you should use a custom template. Not really sure what you mean by empty, because even a blank space is going look empty in the display. A hidden field is probably not what you want because it’s a checkbox…and it can’t be both.

    Don’t mess with the core files…if you want to do some coding to fix this the right way, create a custom template that somehow skips your empty fields (if that’s what you want) anyway, you’ll have all the control you need in that template.

    Check ou this page for some simple instructions how to do that: http://xnau.com/work-2/wordpress-plugins/participants-database/pdb-templates/

    Thread Starter webmoxie

    (@webmoxie)

    What I mean by empty is basically something like <td></td>, so that there is nothing (not even empty space) in between the opening and closing tags. I want that so that I can call td:empty in the css.

    How would I go about skipping my empty fields in a template?

    Thank you so much for your help and speedy response!

    Plugin Author xnau webdesign

    (@xnau)

    I see, well if you’re familiar with WP templates, you should be good with the plugin templates wich are similar. One thing to try is edit the HTML so that no spaces will be added if the field is empty.

    Another approach could be to put a test statement after the “$this->the_field()” statement which checks the value of the field and then does whatever you want it to do if it finds an empty one:

    <?php
    if (empty($field->value) ) $emptyclass = 'empty-field';
    else $emptyclass = ''; ?>

    Then something like this, modifying the code in the template:

    <td class="<?php echo $this->field->name ?>-field <?php echo $emptyclass ?>">
                  <?php $this->field->print_value() ?>
                </td>

    Now all your empty fields will have a handy class name you can use to style it. There are several other things you could do.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Making an unchecked checkbox return empty’ is closed to new replies.