php - WPMVC : Associations -
i have made form wpmvc in add/edit files. form has dropdownlist. dropdownlist doesn't show anything. form information stored in database when press add button.
i use pre defined methods made wpmvc.
those methods are: belongs_to_dropdown , has_many_dropdown
why dropdownlist save not show options in dropdownlist?
controllers/admin/adminsongscontroller.php
<?php class adminsongscontroller extends mvcadmincontroller { var $default_search_joins = array('artist'); var $default_searchable_fields = array('artist.name'); var $default_columns = array('id', 'song_title', 'play_style', 'song_level', 'arrangements_level'); public function add() { $this->set_artists(); $this->create_or_save(); } public function edit() { $this->set_artists(); $this->verify_id_param(); $this->set_object(); $this->create_or_save(); } private function set_artists() { $this->load_model('artist'); $artists = $this->artist->find(array('selects' => array('id', 'name', 'gender'))); $this->set('artists', $artists); } }
?>
models/song.php
<?php class song extends mvcmodel { var $display_field = array('name'); var $belongs_to = array('venue'); var $includes = array('artist'); } ?>
views/admin/add.php
<h2>add song</h2> <?php echo $this->form->create($model->name); ?> <?php echo $this->form->belongs_to_dropdown('artist', $artists, array('style' => 'width: 200px;','empty' => true)); ?> <?php echo $this->form->input('song_title', array('label' => 'songnaam')); ?> <?php echo $this->form->input('play_style', array('label' => 'speelwijze')); ?> <?php echo $this->form->input('song_level', array('label' => 'zangniveau')); ?> <?php echo $this->form->input('arrangements_level', array('label' => 'arrangementsniveau')); ?> <?php echo $this->form->end('add'); ?>
Comments
Post a Comment