Display value at create

edited March 2014 in Modules
Hi, in my database these are my following tables:

course(id,name, ..., ...),
private_course(id, IDcourse,IDuser), both as foreign key, IDcourse to course table and IDuser to users table,
private_courses_requests(id, IDprivate_course, IDemployee, status, comment) IDprivate_course as foreign key to private_courses,
portal_users(id, first_name, last_name, ..., ..., )

When I want to create a private course, it works good, there is a dropdown with users and a dropdown wth courses, but when I want to create a private_course_request the dropdown displays the id of the private_course.

These are my questions:

How can I change the value of the dropdown to display the name of the course instead of the id? I know that it is not displaying the name, because the table private_courses doesn't have that field.

My second question is how can I change the drop_down value when I want to create a private_course to display first_name + last_name, instead of just first_name?

Greetings.

Comments

  • edited 11:43PM
    If this is regarding a module's form field, there is an options parameter that you can overwrite with your own key/value array of options. This may mean you have to do an additional loading of a database table and query to get the options, but it would give you the visual control you want.
  • edited 11:43PM
    Thank you, but now I'm having a problem to access to the method in the model. According to the forms documentation, with this

    $fields['IDuser'] = array( 'type' => 'select', 'model' => array('portal_user' => 'get_admin_names'), 'first_option' => 'Select one...' );

    I would access to the method get_admin_names in my portal_user_model. But it is displaying me this message: "Unable to locate the file: get_admin_names_model.php".

    The key is the model and the value the method, isn't it?
  • edited 11:43PM
    Try the following instead where "app" is the name of the module to look in for the model:
    'model' => array('app' => array('portal_user' => 'get_admin_names')),
Sign In or Register to comment.