I'm trying to replace the value of the selected option in a jump menu from 'Choose' to something else (in my case, the value of a field). What would be the best way to do this? I was looking at views' preprocess & pre_render functions, but that doesn't seem to be the way to accomplish this. Unless I'm missing something.
(While looking into this, I noticed there isn't a tpl.php file for the jump menu style. Is this file intentionally missing?)
| Comment | File | Size | Author |
|---|---|---|---|
| #13 | jump_coose_text.patch | 1.29 KB | brunodbo |
| #11 | jump_coose_text.patch | 1.21 KB | brunodbo |
| #8 | jump_coose_text.patch | 893 bytes | brunodbo |
Comments
Comment #1
dawehnerYou could try to hook_form_alter and check for the formid ctools_jump_menu
Comment #2
brunodboYep, indeed. .. thanks.
Comment #3
brunodboComment #4
brunodboIf anyone else is looking to do this:
Comment #5
merlinofchaos commentedJust to confirm yes, there is intentionally no tpl for the jump menu, because it would be more or less empty -- everything is processed by the form and it would just output one variable.
Comment #6
brunodboThanks.
As an improvement to #4:
will replace the jump menu's default '- Choose -' option with your own selected option (having a value of "" in the select box).
Comment #7
merlinofchaos commentedI seem to recall that the underlying Jump Menu code allows the text for the '- Choose -' to be sent in via function in CTools. If this is true then it would be trivial to add an option in the UI for this.
Comment #8
brunodboSomething like this?
Attached patch adds a text field to the jump menu configuration UI, to supply the text for the 'choose' option. The value is then passed in the render() function and is displayed as the selected option in the select box.
Comment #9
brunodboComment #10
merlinofchaos commentedNeed to add the choose field to the option_definition() for the style or it won't get stored properly in 3.x. Otherwise this is good, I think.
We should probably also just default it to '- Choose -' (set it translatable) and that way it's easy for the user to see what will be used.
Comment #11
brunodboUpdated patch attached.
Comment #12
merlinofchaos commentedOh wow. That - Choose - shouldn't be in t() (which highlights a bug -- the 'Go' above it also should not be in t(). That means those items will get double translated. That's never good.
Comment #13
brunodboAh yes, that makes sense :)
Fixed the t('Go') bug as well (hope it's ok to do this in one patch?).
Comment #14
merlinofchaos commentedCommitted to 2.x and 3.x in D6. Since the jump menu hasn't made it to 7.x marking for porting
Comment #15
dawehnerAnd ported