By Anonymous (not verified) on
Hi, I have a custom entity for which I provide a form. My entity does have Fields API fields attached to it.
Due to the nature of the project I'm working on I have to 'move' certain fields into certan parts of the form. The form is divided into vertical sabs which contains hardcoded fields(for the entity) and optional Field API fields.
What I'm basically doing is something like this:
From:
$form = array(
section => array(type => vertical_tabs)
somesection => array(type => fieldset, group => section)
field_api_field => array(field_definition)
);
to:
$form = array(
section => array(type => vertical_tab)
somesection => array(type => fieldset, group => section)
seomsection[field_api_field] => $form[field_api_field]
...
unset($form[field_api_field]);
);
So I need to know what do I have to do in order to have everything working as it should? For example do I have to alter array_parents/parents of the Field API fields? Or do I have to alter the $form_state['field'] array somehow?
Comments
You can add extra fields that
You can add extra fields that can be rearranged with Drupal fields on the field management page, using hook_field_extra_fields().
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.
Remember that the Form data
Remember that the Form data structure only describes what is in a form. It doesn't actually describe how it is displayed.
Theming is how Drupal actually renders the HTML that pops out of your Web site.
So, you can use theming, probably via your own theme function, to re-arrange the output of the form to your heart's content.
Jaypan, who kindly gave another answer, has a great tutorial about this at http://www.jaypan.com/tutorial/themeing-drupal-7-forms-including-css-and-js.
--
www.ztwistbooks.com. Math books that are actually fun.
You can also check out our
You can also check out our tutorial on View Modes, which refers to hook_field_extra_fields() and how they can be used:
http://www.jaypan.com/tutorial/drupal-7-view-modes-consistently-themeing...
Contact me to contract me for D7 -> D10/11 migrations.
Or anything really. I'm friendly, and open to work or conversation.