Dynamically make a model `displayonly`?

I have a simple module/model where I want to disable editing/deleting a record based on the value of one of those fields. Is this even possible? I've messed around with setting the module's 'displayonly' value to TRUE to no avail. I've set the model to readonly but that doesn't effect the rendering of the form. I could create it as an Advanced Module but then I'd need to recreate the functionality you already have with Fuel's Modules. I'd also love to be able to toggle the availability of the list actions and items actions too if that's possible.

Comments

  • edited May 2019

    You could try to create a callback function for the 'table_actions' module configuration parameter (in fuel/application/config/MY_fuel_modules.php):

    'table_actions' => array('EDIT' => array('func' => function($fields){
    // put your code here
    }), 'DELETE'),
    
  • in the model's form_fields() function, you can set each field's readonly field attribute based on another field's value.

Sign In or Register to comment.