-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Lon Baker wrote:> Does anyone have any suggestions or solutions to multiple submit buttons
> in a single form under rails?
How about using a batch action which dispatches according to submit
button value:
<%= form_tag :action => ''batch'' %>
...
<input type="submit" name="batch_action"
value="Some Action" />
<input type="submit" name="batch_action"
value="Another One" />
</form>
class FooController
BATCH_ACTIONS = {
''Some Action'' => ''bar'',
''Another One'' => ''baz''
}
def batch
if action = BATCH_ACTIONS[@params[''batch_action'']]
send(action)
render_action(action)
end
end
def bar
render_text "bar called from #{action_name}"
end
def baz
render_text "baz called from #{action_name}"
end
end
Beast,
jeremy
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (Darwin)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
iD8DBQFBsTHEAQHALep9HFYRAlhCAJ0XXCy8MHlb/IAgCGi1SCPIsY2P5wCgg98C
WW2GzQ4XPGY0ijMqcSi8s1I=pnqx
-----END PGP SIGNATURE-----