Welcome Guest, Not a member yet? Register   Sign In
Generic list generator helper with templates (ul, ol, select box, etc.)
#12

[eluser]Jelmer[/eluser]
Hey audiopleb,

It's been a while since I've looked at this helper. I never really finished the select part of the function and solved it in a crude way for a select box that needed the current option selected (with preg_replace).

The problem I ran into was how to implement this, mainly because I might want to be able to different kinds of selecting. The best option I thought of, that I haven't implemented until now, was to have an array passed with values you might want selected. That array replaces instances of {SELECTED} with its values in your template where its key is found. It should also have a key "default" that has the default value for replacing when the replacement value is empty.

I think the replacement should probably happen after the alternation.

The array might look like this:
Code:
array(
    'default' => 'selected="selected"',
    'value="something"',
    'value="nothing"' => 'disabled="disabled"',
    'value="second_something"'
);

With which you would replace the {SELECTED} with true selections for the values "something" and "second_something" and disable the value "nothing".

I don't have time to write it now, maybe this weekend I might try it.


Messages In This Thread
Generic list generator helper with templates (ul, ol, select box, etc.) - by El Forum - 03-05-2009, 04:11 AM



Theme © iAndrew 2016 - Forum software by © MyBB