0

I was given a project to update certain extensions and modules on without any documentation.

The issue I'm having is for one of the variables in the model, it is being regarded as not defined when using localhost (but works fine on the server version which is the exact same code).

From what I can see, it makes a single row in the database and assigns it a value of 1 or 0.

What could be causing this?

Keep in mind, this works fine on the server. I have turned global variables in my php.ini to On. No change. The Row is definitely created and exists in the database with a value. The page errors out after clicking "create new group".

Edit. Error message : Property "EventGroups.delegates_select_event_group " is not defined.

Code below is the model, controller and form. (and the options)

First off, the form view.

echo $form->switchGroup($model, 'delegates_select_event_group', array('class' => 'col-md-6'));

Model

public $delegates_select_event_group;

public function rules() {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(

            array('name, description, guest_invites_per_user, delegates_select_event_group ', 'required'),

        );
    }

Options

//Options
// Event group selectable

const KEY_DELEGATES_SELECT_EVENT_GROUP = 'delegates_select_event_group';

public static function isDelegatesSelectEventGroup() {
    return self::getValue(self::KEY_DELEGATES_SELECT_EVENT_GROUP, false);
}

public static function setDelegatesSelectEventGroup($value) {
    return self::setValue(self::KEY_DELEGATES_SELECT_EVENT_GROUP, $value);
}

const KEY_DEFAULT_EVENT_GROUP_ID = 'default_event_group_id';

public static function getDefaultEventGroupID() {
    $model = EventGroups::model()->find();
    if ($model === null) {
        return self::getValue(self::KEY_DEFAULT_EVENT_GROUP_ID, 1);
    } else {
        return self::getValue(self::KEY_DEFAULT_EVENT_GROUP_ID, $model->id);
    }
}

public static function setDefaultEventGroupID($value) {
    return self::setValue(self::KEY_DEFAULT_EVENT_GROUP_ID, $value);
}

Controller

public function actionCreate() {
        $model = new EventGroups;

        // Uncomment the following line if AJAX validation is needed
        $this->performAjaxValidation($model);

        if (isset($_POST['EventGroups'])) {
            $model->attributes = $_POST['EventGroups'];

            if ($model->validate()) {
                // Valid Save 
                $model->save(false);
                $this->redirect(array('event/create'));
            }
        }

    $this->render('create', array(
        'model' => $model,
    ));
}
Alex
  • 673
  • 3
  • 9
  • 22
  • which line or code states undefined? – noobie-php Oct 15 '15 at 10:35
  • 1
    What variable is undefined, at which line? When asking for debug-like problems, please remind providing the **complete error message** along with relevant code. – al'ein Oct 15 '15 at 10:39
  • 1
    Could it simply be that your localhost has turned error reporting on and that your server hasn't ? – Epodax Oct 15 '15 at 10:41
  • edited: Property "EventGroups.delegates_select_event_group " is not defined. Not sure. If error reporting has been turned off, I still don't have full access to the server to check this. – Alex Oct 15 '15 at 10:43
  • Your edit shows an Yii specific exception, the property you're trying to access either does not exist or isn't accessible by the class you're calling it. – al'ein Oct 15 '15 at 10:44
  • Add `error_reporting(E_ALL); ini_set("display_errors", 1);` at the top of your page. (Not sure what file to place it in, never used Yii) – Epodax Oct 15 '15 at 10:45
  • Would that disable the error reporting for that page? i attempted to add it to what I presume is the correct view files but had no luck with it. – Alex Oct 15 '15 at 10:49
  • No, it enables the error reporting (and should be added to the server not displaying the errors,) Try adding it to the file containing the error (at the top of the file, first thing after the ` – Epodax Oct 15 '15 at 10:51
  • No error on the server, works perfectly. All Debugs and error reporting added to the view pages. – Alex Oct 15 '15 at 10:58
  • @Alex we need stack trace not just the error title. we need to know what is happening and what root cause will end to this point. And when you get this error? when you want to show the form or when you are processing the result of this form submitted for the server? – Mohamad Eghlima Jan 19 '16 at 20:34

0 Answers0