Jump to content

Wizard is executing form on load


GriefCode

Recommended Posts

Posted

Hey,

I had this issue previously once already. My form within a step is executed on load of the new step:

issue.thumb.gif.44c930f913efddd60d2a984dfb0318f1.gif

 

This is my code:
 

$steps = []; 
$url = \IPS\Http\Url::internal( 'app=sharedstats&module=report&controller=create', 'front' ); 
[....] 
/** 
 * STEP 1: Account Connection Selection 
 */ 
 $steps['sharedstats_report_create_account'] = function($data) use ($accounts, $names) { 
   $form = new \IPS\Helpers\Form('', 'continue'); 
   $form->addHeader('Select Battle.net Account'); 
   $form->add( new \IPS\Helpers\Form\Select( 'sharedstats_report_select_account', null, true, ['options' => $accounts])); 
   if ($values = $form->values()) { 
       $data['account'] = $names[$values['sharedstats_report_select_account']]; 
    return $data; 
   } 
   return $form; 
 }; 

        /** 
         * STEP 2: Selet Game 
         */ 
        $steps['sharedstats_report_select_game'] = function ($data) use ($names) { 
            $games = $gameIds = []; 
            $i = 0; 

            $acc = isset($data['account']) ? $data['account'] : $names[0]; 


            foreach ((\IPS\DB::i('stats')->select('*', 'stats_gameplayers', array('name=? AND spoofedrealm=?', $acc['name'], $acc['server']), 'id DESC', \IPS\Settings::i()->report_max_last_games)) as $gameplayer) { 
                try { 
                    $game = \IPS\DB::i('stats')->select('*', 'stats_games', array('id=?', $gameplayer['gameid']))->first(); 
                    $dotaPlayer = \IPS\DB::i('stats')->select('*', 'stats_dotaplayers', array('newcolour=? and gameid=?', $gameplayer['colour'], $game['id']))->first(); 
                    $hero = mb_strtoupper($dotaPlayer['hero']); 
                    $gameIds[$i] = $game['id']; 
                    $games[] = $game['gamename']; 
                } catch(\UnderflowException $e) {} 
                ++$i; 
            } 
            $form = new \IPS\Helpers\Form('', 'continue'); 
            $form->addHeader('sharedstats_report_select_game'); 
            $form->add(new \IPS\Helpers\Form\Radio('sharedstats_report_select_recent_game', null, true, array('options' => $games))); 
            if ($values = $form->values()) { 
                $index = $values['sharedstats_report_select_recent_game']; 
                $data['gameid'] = $gameIds[$index]; 
                return $data; 
            } 
            return $form; 
        }; 

What does cause it?

Regards

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...