DropdownList multiple in relation many to many

0

I am implementing a selector for multiple options, the problem is that when passing the model when editing the user the selected values do not come out.

The problem is that the database has the relation between subjects and users and is not able to show the values in the form, if I add only a primary key if it is able to show it but being only the two is not capable .

I do not know if I can assign to the model what is the index of the subjects to show it.

  CREATE TABLE IF NOT EXISTS 'beetic'.'asignaturas_usuarios' (
  'asu_us_id' INT(11) NOT NULL,
  'asu_as_id' INT(11) NOT NULL,
  PRIMARY KEY ('asu_us_id', 'asu_as_id'),
  INDEX 'fk_usuarios_has_asignaturas_asignaturas3_idx' ('asu_as_id' ASC),
  INDEX 'fk_usuarios_has_asignaturas_usuarios3_idx' ('asu_us_id' ASC),
  CONSTRAINT 'fk_usuarios_has_asignaturas_usuarios3'
    FOREIGN KEY ('asu_us_id')
    REFERENCES 'beetic'.'usuarios' ('us_id')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT 'fk_usuarios_has_asignaturas_asignaturas3'
    FOREIGN KEY ('asu_as_id')
    REFERENCES 'beetic'.'asignaturas' ('as_id')
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)
ENGINE = InnoDB
DEFAULT CHARACTER SET = utf8

View:

 <?= $form->field($model, "asignaturasUsuarios")->dropdownList($asignaturas,
                                [
                                    'prompt' => 'Asignaturas',
                                    'class' => 'form-control m-select2',
                                    'id' => 'm_select2_3',
                                    'required' => 'required',
                                    'multiple' => 'multiple'
                                ]
                            )->label(Yii::t('app', 'Asignaturas')); ?>
    
asked by mrbyte89 29.07.2018 в 12:44
source

0 answers