Hide fields on the create form, displayonly on the edit form for a Module

edited June 2012 in Modules
How do you hide certain fields from the Create view of a custom module form in Fuel, but set them to displayonly on the Edit view?

Thanks,
Erik

Comments

  • edited 5:27AM
    I figured it out, the good ol' uri_segment() function:

    if(uri_segment(3) == 'create') { $fields['customer_name']['type'] = 'hidden'; $fields['customer_address']['type'] = 'hidden'; $fields['refund_transaction_id']['type'] = 'hidden'; $fields['refund_transaction_id']['type'] = 'hidden'; $fields['refund_type']['type'] = 'hidden'; } else { // Set Specific Fields to Display Only $fields['customer_name']['displayonly'] = true; $fields['customer_address']['displayonly'] = true; $fields['refund_transaction_id']['displayonly'] = true; $fields['refund_transaction_id']['displayonly'] = true; $fields['refund_type']['displayonly'] = true; }
  • edited 5:27AM
    You can also test for the id value like so:
    if (!isset($values['id'])) { $fields['customer_name']['type'] = 'hidden'; $fields['customer_address']['type'] = 'hidden'; $fields['refund_transaction_id']['type'] = 'hidden'; $fields['refund_transaction_id']['type'] = 'hidden'; $fields['refund_type']['type'] = 'hidden'; } else { // Set Specific Fields to Display Only $fields['customer_name']['displayonly'] = true; $fields['customer_address']['displayonly'] = true; $fields['refund_transaction_id']['displayonly'] = true; $fields['refund_transaction_id']['displayonly'] = true; $fields['refund_type']['displayonly'] = true; }
Sign In or Register to comment.