Modify product fieldsets using hook_form_alter?

Posts: 9
Joined: 04/19/2008

I am successfully modifying core product field attributes (e.g. weight, their title or description) using a custom module and hook_form_alter. However, I have not been able to figure out how to change the configuration of the fieldsets. Ideally, I'd like to remove the fieldsets altogether from the create product page, as I've hidden all unnecessary fields and I want to show the ones I am keeping in the most logical order—which would involve mixing the order of the fields currently in the Ubercart fieldsets with my custom CCK fields.

Any leads? I imagine if it can be done, it will be easy; otherwise, it will be impossible.

I am using Drupal 6.4 if that makes any difference.

Posts: 924
Joined: 11/05/2007
Bug FinderFAQ ModeratorGetting busy with the Ubercode.

You should be able to set the #weight property of the fieldset to change the order, or to eliminate a fieldset entirely you can unset() the $form element. Something like

$form['reordered_fieldset']['#weight'] = -3;

or

unset($form['unwanted_fieldset']);

If that doesn't work, then perhaps you need to make sure your hook is executed after the other hooks which alter the product edit form - some of those fieldsets are inserted by other modules. Do this by altering the {system} table and setting the weight column for your module so it loads after all the other uc_ modules.

--

<tr>.

Posts: 9
Joined: 04/19/2008

That worked perfectly. Unfortunately, I overshot and unset the fieldset that contains where you can set the prices of the products! Hmm. What I want to do is remove the fieldset and the other content in it, but keep the price fields... No doubt this is also easy but I'm feeling a bit stuck (lack of sleep probably not helping Eye-wink)