Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Adding a hidden form item to the comment form

edited October 2010 in Vanilla 2.0 - 2.8
I am trying to add a hidden form item to the comment form, but having a strange problem. The form item is written to the source of the page okay, but when I check the hidden field in Firebug, its value has been reset to an empty string. It is the empty string that is then submitted with the comment.

I assume some kind of javascript is doing this, but I can't think what.

Adding the form item is simple in my plugin:

public function DiscussionController_BeforeDiscussionRender_Handler(&$Sender) {
$Sender->Form->AddHidden('ParentCommentID', '47'); // 47 is just for testing

This ends up in the new comment form source as a hidden field:

<input type="hidden" id="Form_ParentCommentID" name="Comment/ParentCommentID" value="47" />

That's all fine, but then something removes the "47" at the browser end and it gets submitted as "". Viewing the source of the form in Firebug also confirms that the value has disappeared.

Any idea what could be happening here?

-- Jason

PS What's happened to the markdown we used to be able to use here?


  • Options

    I was searching for an answer to this question, not sure if this was in vanilla when you asked the question, but this works for me (at least in a plugin I'm writing for the registration screen)

    echo $this->Form->Input('ParentCommentID', 'hidden', Array('Value'=>47));

Sign In or Register to comment.