I'm integrating Prototype/Scriptaculous into Drupal and I've hit up against a problem with the way that Drupal creates froms with multiple elements here's the code synopsis:

...
<form action="url"  method="post"  id="comment_form">
<input type="text" class="form-text" name="edit[subject]" id="edit- subject" />
 <textarea name="edit[comment]" id="edit-comment" ></textarea>

 <!-- notice the next two lines -->
<input type="submit" class="form-submit" name="op" value="Preview comment" /> <input type="submit" class="form-submit" name="op" value="Post comment" />

</form>

<script type="text/javascript">
  $('comment_form').onsubmit = function() {
new Ajax.Updater('div_id', 'http://example.com/url', {evalScripts:true, method:'post', postBody:Form.serialize(this)});
    return false;
  }
</script>
...

The problem that I'm having is that Drupal is usually able to tell which "op" button was clicked by checking $_POST['op']. But when I do Form.serialize(), I get the value for both "op" buttons and the second one overwrites the first, so that $_POST['op'] is always "Post comment", even if "Preview comment" was selected.

So assuming that the type, name, or value of these buttons is hard coded into Drupal, what is the best way for me to find out which "op" button was used?

Thanks for any pointers.

-Jeff Robbins

_______________________________________________
Rails-spinoffs mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails-spinoffs

Reply via email to