Aaron Posted January 13, 2012 Report Share Posted January 13, 2012 In the admin panel, my rank auto-calculate is set to false, so there is a dropdown box to select the pilots rank. This dropdown box always shows the lowest rank "officer cadet". The same thing happens for the custom field dropdowns. I think I've identified the problem codes but cant figure out why they're wrong. Rank code: <tr> <td>Current Rank</td> <td> <?php if(Config::Get('RANKS_AUTOCALCULATE') == false) { $allranks = RanksData::GetAllRanks(); echo '<select name="rank">'; foreach($allranks as $rank) { echo "<option value=\"{$rank->rankid}\">{$rank->rank}</option>"; } echo '</select>'; } else { echo $pilotinfo->rank; } ?></td> </tr> Custom Field code: <?php if($customfields) { foreach($customfields as $field) { ?> <tr> <td><?php echo $field->title;?></td> <td> <?php if($field->type == 'dropdown') { echo "<select name=\"{$field->fieldname}\">"; $values = explode(',', $field->fieldvalues); if(is_array($values)) { foreach($values as $val) { $sel = ($field->value === $val) ? 'sel="selected"' : ''; $val = trim($val); echo "<option value=\"{$val}\" {$sel} >{$val}</option>"; } } echo '</select>'; } elseif($field->type == 'textarea') ;... rest doesnt apply because text areas show up fine What I'm thinking is wrong is that it it loads the options, but it doesn't load the current value. Any suggestions? Thanks Quote Link to comment Share on other sites More sharing options...
Aaron Posted January 13, 2012 Author Report Share Posted January 13, 2012 I fixed the code for this one, just the formatting messed up now. All the custom field are inline with each other, I tryed adding some </br>'s but none of the worked. Heres the code: <tr> <?php if($customfields) { foreach($customfields as $field) { echo '<td>'.$field->title.'</td> <td>'; if($field->type == 'dropdown') { $field_values = SettingsData::GetField($field->fieldid); $values = explode(',', $field_values->value); echo "<select name=\"{$field->fieldname}\">"; if(is_array($values)) { foreach($values as $val) { $val = trim($val); if($val == $field->value) $sel = " selected "; else $sel = ''; echo "<option value=\"{$val}\" {$sel}>{$val}</option>"; } } echo '</select>'; } elseif($field->type == 'textarea') { echo '<textarea class="customfield_textarea"></textarea>'; } else { echo '<input type="text" name="'.$field->fieldname.'" value="'.$field->value.'" />'; } echo '</td>'; } } ?> </tr> Quote Link to comment Share on other sites More sharing options...
Aaron Posted January 17, 2012 Author Report Share Posted January 17, 2012 Anybody have any ideas to fix the one for the rank Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 17, 2012 Administrators Report Share Posted January 17, 2012 What's the bug, always shows the lowest rank - you mean it's not showing what the person's rank is? Quote Link to comment Share on other sites More sharing options...
Aaron Posted January 17, 2012 Author Report Share Posted January 17, 2012 Ya, it shows the rank properly on the pilot profile, but in the admin center it always shows the lowest rank in the dropdown Quote Link to comment Share on other sites More sharing options...
tutmeister Posted January 18, 2012 Report Share Posted January 18, 2012 The dropdown is loaded from the database, so it's loading by lowest ID. Try changing: echo "<option value=\"{$rank->rankid}\">{$rank->rank}</option>"; to: echo "<option value=\"{$rank->rank}\">{$rank->rank}</option>"; That will sort them alphabetically, not by the unique key from the database table. Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 18, 2012 Administrators Report Share Posted January 18, 2012 The dropdown is loaded from the database, so it's loading by lowest ID. Try changing: echo "<option value=\"{$rank->rankid}\">{$rank->rank}</option>"; to: echo "<option value=\"{$rank->rank}\">{$rank->rank}</option>"; That will sort them alphabetically, not by the unique key from the database table. That will break the saving of the rank, as it's relying on the the ID being in the value Quote Link to comment Share on other sites More sharing options...
Administrators Nabeel Posted January 18, 2012 Administrators Report Share Posted January 18, 2012 File a bug report at github (link in my profile), and I will get around to fixing it soon Quote Link to comment Share on other sites More sharing options...
tutmeister Posted January 18, 2012 Report Share Posted January 18, 2012 That will break the saving of the rank, as it's relying on the the ID being in the value Good point, didn't think of that. Quote Link to comment Share on other sites More sharing options...
Aaron Posted January 24, 2012 Author Report Share Posted January 24, 2012 I'll file it on gihub then I guess, whatever it is. If anybody else has any ideas please let me know, my VA almost fully functional except for the rank thing and a little booking module that I'm making. Quote Link to comment Share on other sites More sharing options...
Aaron Posted February 1, 2012 Author Report Share Posted February 1, 2012 Couldn't find link on your profile, I fixed it myself. In /admin/templates/pilots_details.tpl replace the ranks section with this one: <tr> <td>Current Rank</td> <td> <?php if(Config::Get('RANKS_AUTOCALCULATE') == false) { $allranks = RanksData::GetAllRanks(); echo '<select name="rank">'; foreach($allranks as $rank) { if($pilotinfo->rank == $rank->rank) $sel = ' selected'; else $sel = ''; echo '<option value="'.$rank->rank.'" '.$sel.'>'.$rank->rank.'</option>'; // echo "<option value=\"{$rank->rankid}\" {$sel}>{$rank->rank}</option>"; } echo '</select>'; } else { echo $pilotinfo->rank; } ?></td> </tr> Quote Link to comment Share on other sites More sharing options...
corneyk Posted February 18, 2012 Report Share Posted February 18, 2012 Couldn't find link on your profile, I fixed it myself. In /admin/templates/pilots_details.tpl replace the ranks section with this one: <tr> <td>Current Rank</td> <td> <?php if(Config::Get('RANKS_AUTOCALCULATE') == false) { $allranks = RanksData::GetAllRanks(); echo '<select name="rank">'; foreach($allranks as $rank) { if($pilotinfo->rank == $rank->rank) $sel = ' selected'; else $sel = ''; echo '<option value="'.$rank->rank.'" '.$sel.'>'.$rank->rank.'</option>'; // echo "<option value=\"{$rank->rankid}\" {$sel}>{$rank->rank}</option>"; } echo '</select>'; } else { echo $pilotinfo->rank; } ?></td> </tr> Aaron, I tried it and it works. Great. At first I put the altered template in my Skins directory but it had no effect. I changed the tpl in the Admin folder and it works. I suppose it will revert back to the old template with the next update? Cheers, Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.