Hello,
First of all sorry for my english…
I am developing a app and i cannot extend modules. It always says the same.
I done this:
I created a new file in fronten/models/Example.php
I configure the module in main.php config file
And always same error: it finds ok the file, but “Unable to find ‘app\models\Example’ in file: /var/www/html/advanced/frontend/models/Example.php. Namespace missing?”
I test with 3 different module extends and always same error. It is something that i done wrong.
Example extending RegistrationForm:
namespace app\models;
use dektrium\user\models\Profile;
use dektrium\user\models\RegistrationForm as BaseRegistrationForm;
use dektrium\user\models\User;
class RegistrationForm extends dektrium\user\models\RegistrationForm
{
/**
* Add a new field
* @var string
*/
public $izenAbizenak;
/**
* @inheritdoc
*/
public function rules()
{
$rules = parent::rules();
$rules[] = ['izenAbizenak', 'required'];
$rules[] = ['izenAbizenak', 'string', 'max' => 255];
return $rules;
}
/**
* @inheritdoc
*/
public function attributeLabels()
{
$labels = parent::attributeLabels();
$labels['izenAbizenak'] = \Yii::t('user', 'Name');
return $labels;
}
/**
* @inheritdoc
*/
public function loadAttributes(User $user)
{
// here is the magic happens
$user->setAttributes([
'email' => $this->email,
'username' => $this->username,
'password' => $this->password,
]);
/** @var Profile $profile */
$profile = \Yii::createObject(Profile::className());
$profile->setAttributes([
'izenAbizenak' => $this->izenAbizenak,
]);
$user->setProfile($profile);
}
}
‘modules’ => [
'user' => [
'class' => 'dektrium\user\Module',
'modelMap' => [
'RegistrationForm' => 'app\models\RegistrationForm'
],
If you need i post other examples.
Thank you very much