Zambfd
Member
I have written an addon through which our users can withdraw their quickpoll votes.
Problem is that for this I had to completely override the function "getPollInput" (XF\Helper\Poll) by the addon to add a new field called "remove_vote", because I have not found a way how to add a new field into the existing filters. This is of course impractical when Xenforo changes something here itself. Is there a more elegant way to simply add a new field to the existing poll filters?
Problem is that for this I had to completely override the function "getPollInput" (XF\Helper\Poll) by the addon to add a new field called "remove_vote", because I have not found a way how to add a new field into the existing filters. This is of course impractical when Xenforo changes something here itself. Is there a more elegant way to simply add a new field to the existing poll filters?
Original \XF\Helper\Poll.php
PHP:public function getPollInput(\XF\Http\Request $request) { $input = $request->filter([ 'poll' => [ 'question' => 'str', 'existing_responses' => 'array-str', 'new_responses' => 'array-str', 'max_votes_type' => 'str', 'max_votes_value' => 'uint', 'close' => 'bool', 'remove_close' => 'bool', 'close_length' => 'uint', 'close_units' => 'str', 'change_vote' => 'bool', 'public_votes' => 'bool', 'view_results_unvoted' => 'bool' ], ]); return $input['poll']; }
New \Our_Addon\XF\Helper\Poll.php
PHP:public function getPollInput(Request $request) { $input = $request->filter([ 'poll' => [ 'question' => 'str', 'existing_responses' => 'array-str', 'new_responses' => 'array-str', 'max_votes_type' => 'str', 'max_votes_value' => 'uint', 'close' => 'bool', 'remove_close' => 'bool', 'close_length' => 'uint', 'close_units' => 'str', 'change_vote' => 'bool', 'public_votes' => 'bool', 'remove_vote' => 'bool', 'view_results_unvoted' => 'bool' ], ]); return $input['poll']; }
Last edited: