Forum: Ruby on Rails rails - 2 buttoms on a FORM

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
D5c0c8b6e7ca9b0dd0b640fc1331a85d?d=identicon&s=25 Xd Xd (xads)
on 2008-11-20 21:48
Attachment: ex.doc (80 KB)
then, in my FORM there are 2 buttoms :

first to select a file to upload  buttom="Parcourir"
second to send the complete Form, buttom="ENVOYER"

"parcourir" is for to select a file to upload

but "ENVOYER" must validate the complete Form :
- file selected presence
- other fields validatation

if evrything is OK, i have to upload the file (and save it)
and update a Table


how can i do this ?
4ddf8432a838f716cc499e43131e5e58?d=identicon&s=25 James Englert (Guest)
on 2008-11-21 00:35
(Received via mailing list)
You could use javascript to change the target of your form when they
click
either button. This can get messy though.  Each different form target
can
have it's own validation.

-Jim
http://jim-rants.com/coding-blog/
Be07c8d0d6867fd9a0d525f7d17600e2?d=identicon&s=25 Damjan Rems (ther)
on 2008-11-21 07:59
I guess you want to diferenciate clicks to different submit buttons. I
did it like this:

<%= image_submit_tag('add_16.png', :name => "action_categories/new") %>

By specifiing name you can differenciate in controller which button was
selected.

params.each do |e|
  if e[0][0,7] == 'action_'
    ctrl, action = e[0][7,100].split('/')
    action ||= 'index'
    break
  end
end

The example shows which controller/action call when submit button is
pressed.


by
TheR
81b61875e41eaa58887543635d556fca?d=identicon&s=25 Frederick Cheung (Guest)
on 2008-11-21 12:06
(Received via mailing list)
On 20 Nov 2008, at 20:48, Xd Xd wrote:

>
> then, in my FORM there are 2 buttoms :
>
> first to select a file to upload  buttom="Parcourir"
> second to send the complete Form, buttom="ENVOYER"
>
> "parcourir" is for to select a file to upload
>
Isn't this button just going to come "for free" was part of the file
upload tag?

Fred
This topic is locked and can not be replied to.