Can I extend the fieldset to go around my custom fields?

Posts: 20
Joined: 09/23/2008

I have another question. Since I'm new to module writing and coding, as an exercise, I went through and modified my form by using hook form alter()

This is what I have now:

<?php
// $Id$

/**
* @file
* Module to hold my customizations to Ubercart
*/

/**
* Implementation of hook_form_alter()
*/
function disable_module_form_alter(&$form, &$form_state, $form_id ) {
if ($form_id == 'product_node_form') {
    $form['base']['model']['#required'] = FALSE;
    $form ['base']['prices']['sell_price']['#required'] = FALSE;
    //modify attributes of existing fields
    $form['base']['prices']['sell_price'] = array('#type' => 'hidden');
    $form['base']['prices']['cost'] = array('#type' => 'hidden');
    $form['base']['prices']['list_price'] = array('#type' => 'hidden');
    $form['base']['shippable'] = array('#type' => 'hidden');
    $form['base']['weight'] = array('#type' => 'hidden');
    $form['base']['dimensions'] = array('#type' => 'hidden');
    $form['base']['pkg_qty'] = array('#type' => 'hidden');
    $form['base']['default_qty'] = array('#type' => 'hidden');
    $form['base']['ordering'] = array('#type' => 'hidden');
  
    }

}

The only field I left in the "Product Information" fieldset was the SKU field. My new question is , how do i expand the field set to extend around all of my other unique product information fields that I have added.
I found the code easily in the ubercart product module, but I'm not sure what to do to extend it. I think it has something to do with adding the variable [base] to all my new fields but I don't know how to do it.
Ubercart code
$form['base'] = array('#type' => 'fieldset',
    '#title' => t('Product information'),
    '#collapsible' => true,
    '#collapsed' => false,
    '#weight' => -1,
    '#attributes' => array('class' => 'product-field'),
  );

I know how to add a custom filed to the file and make it go in the same fieldset. I found out here: http://www.molecularsciences.org/drupal/modifying_your_forms But, what do i do if i have unique fields that i made in cck that i want the field set to go around?

Thanks

raspberryheaven

Posts: 20
Joined: 09/23/2008

Also I just tested a field out that i made by adding

$form['base']['testfield'] = array(
    '#type' => 'textfield',
    '#title' => t('Testfiled'),
    '#default_value' => $node->testfield,
    '#required' => false);
   )

and even though it made the field, I couldn't get any thing i typed in it to show up after I had saved the form. So i made a field called testfield. Typed a value in it, it was just a text field and then save. the value wouldn't show up on the page.
Not sure what to do now...

Posts: 2357
Joined: 08/07/2007
AdministratoreLiTe!

hook_form_alter() is only half of the solution. The other half is hook_nodeapi(). There, you will need to save the values of the fields in some way (usually a database table). Check out uc_quote, or maybe the taxonomy module.

Posts: 20
Joined: 09/23/2008

Well, lets say that I don't care about making my fields the way i tried to above and just want the [base] value to get stuck to my other CCK fields instead. How would I do that?
I will check out the modules you suggested though.

Thanks,
raspberryheaven