Drop down in a form from table

edited April 2012 in Modules
I have to join 3 tables and have to get the party name from the party table and description id from description table and i want both party name and description id in a drop down i am not getting, i am a newbie to this could anyone explain me where i am going wrong


public function form_fields($values = array())
{
$fields = parent::form_fields($values);

$fields_2['Number'] = parent::form_fields();
$fields_2['Date'] = parent::form_fields();
$fields_2['country'] = parent::form_fields();
$fields_2['state'] = parent::form_fields();
$fields_2['Width'] = parent::form_fields();
$fields_2['Thickness'] = parent::form_fields();
$fields_2['Weight'] = parent::form_fields();
$fields_2['Length'] = parent::form_fields();

$this->load->module_model(PARTYWISE_REGISTER_FOLDER, 'partywise_register_model');
$this->load->module_model(PARTYWISE_REGISTER_FOLDER, 'aspen_tblowner_model');
$fields_1['partyname'] = $this->partywise_register_model->form_fields();

$fields_3['descid'] = $this->partywise_register_model->form_fields();
$fields = array_merge($fields_1, $fields_2,$fields_3);
$this->form_builder->set_fields($fields);
return $fields;
}

Comments

  • edited 1:26AM
    I don't think you are wanting to call parent::form_fields(); more then once like you are for all the $fields_2. It sounds like what you are needing for a dropdown would be something like this:
    public function form_fields($values = array()) { $fields = parent::form_fields($values); .... $this->load->module_model(PARTYWISE_REGISTER_FOLDER, 'partywise_register_model'); // a custom method on your partywise_register_model that returns an associative array with the corresponding options with the desc_id as the key and the party name as the value $options = $this->partywise_register_model->my_custom_options(); $fields['party'] = array('type' => 'select', 'options' => $options', 'first_option' => 'Select a description...'); .... return $fields; }
    You will need to create the method on your model of "my_custom_options" to return the associative array of options.
  • edited 1:26AM
    Thanks a lot appreciated for your help
Sign In or Register to comment.