Advanced field type in create mode

edited August 2014 in Modules
Hi I need to change field: chantier_id from simple int field to dropdown with the what will have the value=chantier_id and relation with chantiers model, where i have id field and will be shown the text = chantier's name.

Although I don't want change field name and buttons `add` and `edit` don't must appers like it's doing using:

public $foreign_keys = array('chantier_id' => array(FUEL_FOLDER => 'fuel_chantiers_model', 'order' => 'id desc') );

Screen: http://puu.sh/aFs4o/54ba8c62b2.png

Can you help me with this issue, please.

Comments

  • edited 8:32PM
    I'm sorry but I don't think I'm quite understanding your question/issue.
  • edited 8:32PM
    I have created 2 modules: Fuel_chantiers_model and Fuel_levels_model.
    Fuel_chantiers_model has: id, name, description, address, active - fields
    Fuel_levels_model has: id, name, rank, map, chantier_id, active - fields
    When I'm creating new item in levels module I need that chantier_id field was dropdown field with names fields from Fuel_chantiers_model and returning id in the end.
    I'm using this functionality to implement this: public $foreign_keys = array('chantier_id' => array(FUEL_FOLDER => 'fuel_chantiers_model', 'order' => 'id desc') );
    And what I have in the end is : http://puu.sh/aGKzK/db0d08b748.png.
    So I don't need to change chantier_id field to Fuel chantier as you can see on the screen, and also there appears buttons to add or to edit chosen chantier item, what I also don't need. If there any abilities to customize this change field name to chantier_id and remove those buttons ( http://puu.sh/aGKL5/7666f94b68.png ) ?
  • edited 8:32PM
    You can overwrite these in your form_fields method on your model:
    ... $fields['chantier_id']['label'] = 'Chantier'; $fields['chantier_id']['module'] = NULL; ...
  • edited 8:32PM
    Works, Thank you
Sign In or Register to comment.