0

Hi, i bought a framework website which i am altering for a client and i am trying to add a new feature to it.
i have added new field to mysql table
i have added lines of code to show up on form, the choice in new feature will be 'manual' or 'automatic'.
and im stuck with the code as it keeps adding manual, no matter what i choose.

in mysql i added new field called 'transmissiontype' and data type of 'enum' with length/values set to 'manual' and 'automatic' and set a default of 'manual'

my object is have a select box showing manual and automatic, defaulted to manual.
i have added this line where the form is asking for info, it errors when submitting and im sure this bits wrong, but cannot see the wood for the forrest

        ( isset($_POST['transmissionTypeInput']) ? $transmission_type = (bool)($_POST['transmissionTypeInput']) : $transmission_type = false );
        ( $transmission_type ? $transmission_type = 'manual' : $transmission_type = 'automatic' );

there is another file which is the front end form and the previous code was from a file which is the controller, this next bit of code is from the main form

<!-- adding transmission type **** manual and automatic ****  --> <div class="input-prepend"> <span class="add-on" style="width:150px;overflow:hidden;"><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_LABEL'];?></span> <select name="transmissionTypeInput" style="width:569px;"> <?php
                                $automatic = '';
                                $manual = '';
                                if( isset($_SESSION['vin_session']) ){
                                    if( $_SESSION['vin_session']['automatic'] ){
                                        $automatic = 'selected="selected"';
                                    } else {
                                        $manual = 'selected="selected"';
                                    }
                                }
                            ?> <option value="manual" <?php echo $manual;?>><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_OPTION_MANUAL'];?></option> <option value="automatic" <?php echo $automatic;?>><?php echo $_LANG['NEW_VEHICLE_TRANSMISSION_TYPE_OPTION_AUTOMATIC'];?></option> </select> </div> <!--  end of adding transmission type **** manual and automatic **** -->

my form tells me there is an internal error, i have tried adding debugging, but wont show up

help please obi-wan

3
Contributors
5
Replies
33
Views
1 Year
Discussion Span
Last Post by yaginuk
1
$transmission_type = ( isset($_POST['transmissionTypeInput']) && $_POST['transmissionTypeInput']=='automatic' ? 'automatic' : 'manual' );

Edited by AndrisP

Votes + Comments
I misread OP request and focused on the first bit of code... correct solution +1
0

thanks for the quick reply,
before i try it there is a big block of code it start like this

    private function saveVehicleForm(){
        ( isset($_POST['stockInput']) ? $stock = trim($_POST['stockInput']) : $stock = '' );
........(lots more issets)
/** -my bit- adding transmission type ***/

        ( isset($_POST['transmissionTypeInput']) ? $transmission_type = (bool)($_POST['transmissionTypeInput']) : $transmission_type = false );
        ( $transmission_type ? $transmission_type = 'manual' : $transmission_type = 'automatic' );

/** end of -my bit- adding transmission type **/
(........(more issets)
        require_once BASE_CLASS . 'class-utilities.php';

the code you guys replyed with is way different, to the surround code, if i change it will it upset the surround flow?

0

OOP its easy:

class Vehicle {
    public $transmission='manual'; // default value for transmission
    public $doors=4; // default value for doors
    public $engine; // without default value

    private function saveVehicleForm(){
        if(isset($_POST['transmissionTypeInput'])){
        $this->transmission = $_POST['transmissionTypeInput'];
        }
        if(isset($_POST['doors'])){
        $this->doors = $_POST['doors'];
        }
        // etc...
    }
}
0

thanks andris,

but this file is 630 lines, there are a handful of other file which are of a similar code structure, i dont want to have to redo all their work, all i want to do is add a select box to a form to choose auto or manual.

just to let you know, with this framework the page i am changing has other files linked to it

view/pages/user-new-vehicle.php
view/css/user-new-vehicle.css
view/js/user-new-vehicle.js
controller/user-new-vehicle.php
language/en/user-new-vehicle.php

as you see this 1 page on the site, it has 5 files liked to it to work correctly, and if i have to change more than 1 page then i have lots to do

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.