Search code examples
modelyiigii

Yii, ActiveDateSelect must specify "model" and "attribute" or "name" property values


I am using ActiveDateSelect extension to get the month, year details from the user. Everything goes fine. When i try to generate model using gii module i am getting the error. The stack trace says

\protected\extensions\ActiveDateSelect.php(120): CInputWidget->resolveNameID()

I can understand the problem by looking at the code of CInputWidget class. Not sure how to fix the error. If comment this extension configuration from main.php file, i am able to generate models using gii.

 'ActiveDateSelect' => array(
      'class' => 'ext.ActiveDateSelect',
  ),

Solution

  • So the real issue (from comments) seems that you want to autoload the extension. Well actually the way you are trying auto-loading is wrong, to autoload the extension do this instead(in config/main.php):

    'import'=>array(
        'application.models.*',
        'application.components.*',
        'ext.ActiveDateSelect' // add this line to the already existing import array
    ),
    

    Now you can use in view directly like so:

    $this->widget('ActiveDateSelect', array (
        // whatever configuration
    ));
    

    Or anywhere else like so:

    ActiveDateSelect::sanitize($model, 'birthdate'); // example from the extension's page