ludak
Active member
I am trying to add multiple items in the database using the form submit. I know I can pass the object individual to template and then change it and then save, and post that object. That works fine. It would be in the save ParameterBag and I can do it.
I am wondering what if I am about to open a overlay and create a list of items automatically. And then let the user make selection absed on the list. and click save.
So before hand I create number of rows (games) based on the option for that tournament.
AND PASS THAT to the template... which renders this...
Basically what I am asking is, this is gonna have a list of player a vs player b in dropdown. I will select which players are playing with who, and then, I will save it.
I want the RESULT to be editable, so that admin can go back to edit this and save the final result.
So basically I would want to iterate trough this form and when click save save the LIST of Entity Game. In the controller save action I would then iterate through that list and save the items in the database.
Is this possible like this?
I am wondering what if I am about to open a overlay and create a list of items automatically. And then let the user make selection absed on the list. and click save.
So before hand I create number of rows (games) based on the option for that tournament.
Code:
for($i = 0; $i < $rows;$i++){
$game = $this->em()->create('XX:Game');
$game->game_id = $i+1;
array_push($games, $game);
}
AND PASS THAT to the template... which renders this...
Code:
<xf:form action="{{ link('xx/games/save') }}" ajax="true" class="block">
<div class="block-container">
<div class="block-body">
<xf:datalist data-xf-init="responsive-data-list">
<xf:datarow rowtype="header">
<xf:cell>{{ phrase('player_a') }}</xf:cell>
<xf:cell>{{ phrase('vs') }}</xf:cell>
<xf:cell>{{ phrase('player_b') }}</xf:cell>
<xf:cell>{{ phrase('result') }}</xf:cell>
</xf:datarow>
<xf:foreach loop="$games" value="$game">
<xf:datarow>
<xf:cell>
<xf:select name="player_a_id[{$game.game_id}]" value="{$game.player_a_id}">
<xf:foreach loop="$players" value="$player">
<xf:option value="{$player.player_id}">{$player.player_name}</xf:option>
</xf:foreach>
</xf:select>
</xf:cell>
<xf:cell>vs.</xf:cell>
<xf:cell>
<xf:select name="player_b_id[{$game.game_id}]" value="{$game.player_b_id}">
<xf:foreach loop="$players" value="$player">
<xf:option value="{$player.player_id}">{$player.player_name}</xf:option>
</xf:foreach>
</xf:select>
</xf:cell>
<xf:cell>
<xf:select name="resuly" value="{$game.result}">
<xf:option value=""></xf:option>
<xf:option value="1">1</xf:option>
<xf:option value="x">X</xf:option>
<xf:option value="2">2</xf:option>
</xf:select>
</xf:cell>
</xf:datarow>
</xf:foreach>
</xf:datalist>
</div>
<xf:submitrow sticky="true" icon="save" />
</div>
</xf:form>
Basically what I am asking is, this is gonna have a list of player a vs player b in dropdown. I will select which players are playing with who, and then, I will save it.
I want the RESULT to be editable, so that admin can go back to edit this and save the final result.
So basically I would want to iterate trough this form and when click save save the LIST of Entity Game. In the controller save action I would then iterate through that list and save the items in the database.
Is this possible like this?