Hello everyone,
I’ve seen that I always make the same modifications to the CJuiDatePicker attributes, so I’d like to define a function that I can call to create a CJuiDatePicker in my views. I’d like to be able to use something like this, in my views:
<?php MyGeneralClass::createDatePicker('myDatePickerName', $myDatePickerValue); ?>
so I tried defining this class in my "models" folder:
<?php
class MyGeneralClass
{
public static function createDatePicker($name, $value)
{
return $this->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>$name,
'value'=>$value,
// etc...
));
}
}
?>
But, “$this” can’t be used there, so I tried receiving the “$this” reference, this way:
<?php
class MyGeneralClass
{
public static function createDatePicker($name, $value, $owner)
{
return $owner->widget('zii.widgets.jui.CJuiDatePicker', array(
'name'=>$name,
'value'=>$value,
// etc...
));
}
}
?>
And it’s working calling the function this way:
<?php MyGeneralClass::createDatePicker('myDatePickerName', $myDatePickerValue, $this); ?>
But I’m not sure about passing the whole “$this” reference from my views all the time. Is there a way to avoid this? Is there a way to create a CJuiDatePicker in my views without sending the whole “$this” reference to my class (model)?
Your help is appreciated. Thank you in advance.