255], ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => 'ID', 'nom' => 'Nom', 'siret' => 'Siret', 'logo' => 'Logo', 'photo' => 'Photo', 'description' => 'Description', 'code_postal' => 'Code postal', 'ville' => 'Ville', ]; } public static function getEtablissementsPopulateDropdown() { $etablissements_dispos = Etablissement::find() ->orderby('code_postal, ville ASC') ->all() ; $departements = Departements::get() ; $data_etablissements_dispos = [] ; $options_etablissements_dispos = [] ; foreach($etablissements_dispos as $e) { if(!key_exists('d'. substr($e['code_postal'], 0, 2), $data_etablissements_dispos)) { $data_etablissements_dispos['d'. substr($e['code_postal'], 0, 2)] = ''.$departements[substr($e['code_postal'], 0, 2)].'' ; $options_etablissements_dispos['d'. substr($e['code_postal'], 0, 2)] = ['disabled' => true] ; } $data_etablissements_dispos[$e['id']] = Html::encode($e['nom']).' - '.Html::encode($e['code_postal']).' '.Html::encode($e['ville']) ; } return ['data' => $data_etablissements_dispos, 'options' => $options_etablissements_dispos] ; } }