Using function phptemplate_node_form($form) I can override parts of the default Drupal node add/edit form. (I use this to change things like Groups to Access Groups and to re-order the fieldsets.)
When I override the default node edit/add forms using Panels, is there an equivalent function to phptemplate_node_form for Panels?
Comments
Comment #1
ianchan commentedBad subject line - closing and re-posting... sorry!
Comment #2
pendashteh commentedhere is the problem:
i have a THEME_them() that makes drupal uses form-node.tpl.php to theme a form. but this does not happen when the form is called from a Panel.
how could i have a .tpl.php file to theme a form which is called from a Panel?
Comment #3
merlinofchaos commentedYou can't. They're not compatible techniques, you cannot use them together.
Comment #4
pendashteh commentedok, i read the panels.module and ctools.module carefully.
here is what i found about the problem:
assume you have created a panel for replacing node/%/edit pages.
and your panel have got two panes. the first for your node form and the other for a simple block for example.
simple say, Panels renders your form with theme_markup($form); not with theme_node_form($form); nor with whatever you has defined.
then after rendering all panes it renders whole panel with theme_form(); just to wrap the output with form tag
according above:
final note:
i think the way that Panels handles form pages, wrapping whole panel with form tag, is not a appropriate at all.
it is enough to let the form be rendered inside the pane. or at least let user choose the behaiviour.
i mark this as major priority because the user have no chance to theme the form and this makes node edit panel pages mostly unusable.
feature request
change the behavior of form panels so form renders inside panes. by doing this users may use other forms in other panes and they can have control over form theming and managing fields.
Comment #5
pendashteh commenteda trick to take control over the form:
Comment #6
sigent commentedno-no, that's misstep.
"theme_markup" works with the fully rendered form and does nothing except this:
"
function theme_markup($element) {
return (isset($element['#value']) ? $element['#value'] : '') . (isset($element['#children']) ? $element['#children'] : '');
}
"
what i do is overriding the function
THEME_panels_render_display_form(&$form)
(originally it's a very tiny function, check panels.module file)
the needed data are deep inside the variable:
form data - $form['#display']->context[argument_node_edit_1]->form;
form id - $form['form_id']['#value']
!!! be careful this function was changed between panels 3.6 and 3.7
(i had to fix it a little too -- re-copy original code from panels.module)
Comment #7
Mark F commentedOk, so I'm stuck! I themed the form with panels disabled for the node/edit page. When I re-enabled panels node/edit page, back to the original form. This is when I stumbled upon your post!
So, in #6, I changed (in template.php) THEME_node_form to THEME_panels_render_display_form, and also changed the hook to the same. I am now back at the point where panels appears to be disabled - no panels formatting. I guess I'm missing something. Any clues?
Comment #8
merlinofchaos commentedMy response in #3 covers it.
You can't both theme the node form and use Panels, because it uses the theming layer to do its job.
Comment #9
Mark F commentedThanks for wrapping that one up for me! Could have been on for days!
Comment #10
merlinofchaos commentedFYI, a lot of what you would normally want to accomplish using theme_node_form you can accomplish with a hook_form_alter instead, I think. Ideally, you use the panel to do most of the actual theming and the form_alter to move stuff around or add it.
For some purposes, you can also create mini content type plugins to handle moving form items around that Panels doesn't know about/support. Look in ctools/content_types/node_form -- mostly it's just a cut & paste job and figuring out what the items are referred to in the form.