0

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',
  ),
  • I moved the code `list($name) = $this->resolveNameID()` from the `init()` function call to the `run()`. Its solved my problem and extension also working fine. But not sure it is a valid fix? – Suriyamoorthy Baskaran Oct 26 '12 at 11:19
  • i don't think it's a valid fix, because looking at the source, `$name` is being used within the `init()` function again. Why are you using trying extension configuration in `main.php`? Why not do it in the view directly? There could be another way to get this done, so let me know the answers to my queries, and maybe i could help you figure out a better solution. – bool.dev Oct 26 '12 at 12:10
  • @bool.dev, I have moved that code `... $this->field_order = strtoupper($this->field_order);` as well to `run()` function. Sorry i didnt mention it in my comments. **Why are you using trying extension configuration in main.php?** It will be autoloaded, i dont need to import where ever i am using this extension. – Suriyamoorthy Baskaran Oct 26 '12 at 12:22
  • well that's where you are mistaken, let me type answer then – bool.dev Oct 26 '12 at 12:28

1 Answers1

0

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
Community
  • 1
  • 1
bool.dev
  • 17,508
  • 5
  • 69
  • 93
  • 1
    You are correct. I messed up b/w import & component section. Thanks !! Could you plz take a look at my one more post here. [http://stackoverflow.com/questions/13084032/yii-model-behaviour-in-sub-class-inherits-the-ar-model-class] – Suriyamoorthy Baskaran Oct 26 '12 at 12:41