1

i'm trying to override some fields in commerce_products_ui form in my-module, i need to 'disable' or 'hide' some fields, this question is similar to this one, it does not have an accepted answer and it does not work, i think the problem is that form_id is incorrect, code does not even dpm($form), i've google arround looking for correct hook and form_id, but nothing helpfull came up, i use my_module_form_alter() because i use it to modify several forms, i stripped other forms code, this is my code:

 function my_module_form_alter(&$form, &$form_state, $form_id) {
          global $user;
          //$account = $user;
          $uuid = $user->uid;
    /*  check that user is NOT admin (No1) */
      if ($uuid !='1') {

           // FIRST ATTEMPT 
           if ($form_id == 'commerce_product_product_form') {
               //dsm($form);
               hide($form['commerce_price']);
               $form['field_my_field']['#disabled'] = TRUE;
            }

            // SECOND ATTEMPT
            if ($form_id == 'commerce-product-ui-product-form') {
                //dsm($form);
                hide($form['commerce_price']);
                $form['field_my_field']['#disabled'] = TRUE; 
             }
        }

comments on my code: inspecting code in mozzilla it says formd_id = 'commerce-product-ui-product-form' (second attempt in my code), but from a very old commerce issue answered by Ryan Szrama he suggest to use 'commerce_product_product_form' instead (first attempt in my code), any help will be very appreciated. regards.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.