Pending

User tests: Successful: Unsuccessful:

avatar Chraneco Chraneco - open - 11 Oct 2012
avatar shumisha
shumisha - comment - 20 Oct 2012

Hi
I think this could be made more generic, and prepare for future improvement. For instance:
1 - add a type param instead of $custom
public static function addFilter($label, $name, $options, $noDefault = false, $type = 'select')
2 - then in layout file:

        <?php foreach ($displayData->filters as $filter) :
          switch($filter['type']) :
            case 'select': ?>

            <label for="<?php echo $filter['name']; ?>" class="element-invisible"><?php echo $filter['label']; ?></label>
            <select name="<?php echo $filter['name']; ?>" id="<?php echo $filter['name']; ?>" class="span12 small" onchange="this.form.submit()">
                <?php if (!$filter['noDefault']) : ?>
                    <option value=""><?php echo $filter['label']; ?></option>
                <?php endif; ?>
                <?php echo $filter['options']; ?>
            </select>
            <?php 
            break;
            case 'custom':
                echo $filter['custom'];
            break;

            // maybe more filter types in the future
            endswitch;
            ?>
            <hr class="hr-condensed" />
        <?php endforeach; ?>

Note that in the case of real "custom" filter, I think we should not add any markup at all ourselves (ie no ) as this is really up to the caller, and maybe they don't want a label (this could be used to display an help text for instance or something else.
So maybe we also want to add a simple
public static function addCustomFilter( $customFilter)
to let extensions add real raw filter

What do you think?

avatar elinw
elinw - comment - 12 May 2013

I think that's a great idea.

avatar phproberto phproberto - close - 5 Oct 2013
avatar phproberto
phproberto - comment - 5 Oct 2013

Closing this because it's not mergeable anymore and the solution is still being discussed. Feel free to reopen it if you update the code.

Thanks for contributing!

Add a Comment

Login with GitHub to post a comment