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.

Hook to every form

Is there any hook in vanilla so that i can add content before every form close?

Tagged:

Comments

  • There is no shortage of hooks.

    You might also what to try the pockets plugin, if you wan to add static content quickly.

    grep is your friend.

  • amalfraamalfra New
    edited September 2014

    @x00 said:
    There is no shortage of hooks.

    You might also what to try the pockets plugin, if you wan to add static content quickly.

    Hi, thanks for the quick reply. I am new to vanilla and was looking for where i can find a list of available hook?

  • The closing of a form most probably is done because the content of the form should be saved. So you could do a full text search for "BeforeSave". But that way you would have to hook in every event that you can find.

    Sometimes it is helpful to also state what you are trying to achieve in order to get tips from the community about the best way to achieve your goal.

  • BeforeSave would be a model hook. I didn't interpret this as adding content to the post itself, but to the form. But like you say it is not clear.

    grep is your friend.

  • @R_J said:
    The closing of a form most probably is done because the content of the form should be saved. So you could do a full text search for "BeforeSave". But that way you would have to hook in every event that you can find.

    Sometimes it is helpful to also state what you are trying to achieve in order to get tips from the community about the best way to achieve your goal.

    Goal is to put a hidden field at every form.

  • Ah why didn't you say so?

    grep is your friend.

  • @x00 said:
    Ah why didn't you say so?

    Sorry that i didn't explain in detail. Is there any hook? I tried Gdn_Form_Close_Before but didn't work,,,

  • x00x00 MVP
    edited September 2014

    The only guaranteed hook for form is BeforeBodyBox and that only applies to forms with body boxes.

    I presume you mean comment and discussion forms?

    You actually should set hidden values before form is opened the inclusion at the end is automatic.

    $Sender->Form->AddHidden('YourField' 'Your Value');

    Therefore you will just need a suitably early hook for every controller relevant to the views.

    grep is your friend.

  • PostController_BeforeCommentRender and PostController_BeforeDiscussionRender

    grep is your friend.

  • Okay... Thanks...

  • Sorry the inclusion is actually at the beginning but that should not matter anyway.

    grep is your friend.

  • If you add a field to a form, even if it is hidden, it could be very easy manipulated before the form is sent. So you might want to set a special value only after the form has been sent or at least want to validate that field. I would recommend using the BeforeSave events to do so.

    Otherwise the information sent with the from is not reliable.

    Could you be even more precise on what you want to achieve?

Sign In or Register to comment.