i added a edit button so players who play the Match can send the winner, a link to the replay and/or stream vod (it means that only 2 players be able to edit in each box) using a route/controller and Ajax function (data-ajax) i load a popup with a form when you click on edit:
I create this form in my controller and send it as json response and finally append into html with javascript.
code (form part):
Code: Select all
$url = $this->helper->route('agros_system_battle', array('id' => $id,'mode' => 'edit','s' => generate_link_hash('upload')));
$html = '<form class="modal-form" method="post" action="'. $url .'" data-ajax="editar" ><div id="choose-winner-label">Choose a winner</div><div class="modal-choose-winner"><div class="display-winners"><label class="radio-img" data-id="'. $battle['battle_pl1'] .'"><input type="radio" tabindex="1" name="winner" class="visual-radio" value="'.$battle['battle_pl1'].'" '. $check1 .'></label><span id="modal-lineup"></span><label class="radio-img" data-id="'. $battle['battle_pl2'] .'"><input type="radio" tabindex="2" name="winner" class="visual-radio" value="'.$battle['battle_pl2'].'" '. $check2 .'></label></div></div><div class="modal-replay"><dl style="clear: left;"><dt><label for="username">Replays from this match</label></dt><dd><input type="text" tabindex="3" name="replay" id="replay_link" size="25" value="'. $battle['battle_replay'] .'" class="autoselect readonly"><a class="modal-button" id="goto-replay" href=""><i class="fa fa-external-link-square" aria-hidden="true"></i></a></dd></dl></div><div class="modal-stream"><dl style="clear: left;"><dt><label for="username">Streamer channel</label></dt><dd><input type="text" tabindex="4" name="stream" id="stream_link" size="25" value="'.$battle['battle_stream'].'" class="goto autoselect readonly"><a class="modal-button" id="goto-stream" href=""><i class="fa fa-external-link-square" aria-hidden="true"></i></a></dd></dl></div><div id="modal-action"><input type="submit" accesskey="s" tabindex="5" class="button1 default-submit-action"></div></form>';
$response->send($html);
Code: Select all
public function user_battle($id)
{
if($this->user->data['username'] != 'Anonymous' && $this->request->is_ajax()) <- fail at this point :(
{