Hello guys!
I’m trying to use DepDrop from kartik, but the function “depends” is not working… this is not my first time with this extension but this time is not working and i have not finded the solution, i just have an error in my console, and it’s says ;
“depdrop_b737edba is not defined”
the code is very simple
View:
use yii\helpers\Html;
use yii\helpers\Url;
use yii\helpers\ArrayHelper;
use yii\widgets\ActiveForm;
use kartik\depdrop\DepDrop;
use app\models\AventurasSearch;
use app\models\Aventuras;
use app\models\NivelAventura;
use app\models\NivelAventuraSearch;
$form = ActiveForm::begin([
'action' => ['index'],
'method' =>'post',
'options' => [
'enctype' => 'multipart/form-data'
]
]);
echo $form->field($avModel,'nombre')->dropDownList(
ArrayHelper::map(
Aventuras::find()->all(),
'id',
'nombre'),
[
'prompt' =>'Tipo de Aventura'
]
)->label(false);
echo $form->field($avModel, 'descripcion')->widget(DepDrop::classname(), [
'pluginOptions'=>[
'depends'=>['aventuras-nombre'],
'placeholder'=>'Select...',
'url'=>Url::to(['/site/subcat'])
]
]);
<div class="form-group">
Html::submitButton('Submit', ['class' => 'btn btn-primary'])
</div>
ActiveForm::end();
My $avModel :
namespace app\models;
use Yii;
/**
-
This is the model class for table “aventuras”.
-
-
@property int $id
-
@property string|null $nombre
-
@property string|null $imagen
-
@property string|null $descripcion
-
@property string|null $titulo
-
@property int $nivel_id
/
class Aventuras extends \yii\db\ActiveRecord
{
/*
- {@inheritdoc}
*/
public static function tableName()
{
return ‘aventuras’;
}
/**
- {@inheritdoc}
*/
public function rules()
{
return [
[[‘nivel_id’], ‘required’],
[[‘nivel_id’], ‘integer’],
[[‘nombre’, ‘imagen’, ‘descripcion’, ‘titulo’], ‘string’, ‘max’ => 255],
];
}
/**
- {@inheritdoc}
*/
public function attributeLabels()
{
return [
‘id’ => ‘ID’,
‘nombre’ => ‘Nombre’,
‘imagen’ => ‘Imagen’,
‘descripcion’ => ‘Descripcion’,
‘titulo’ => ‘Titulo’,
‘nivel_id’ => ‘Nivel ID’,
];
}
}