Error defining parameters in hook_theme
In a module I'm creating, I'm embedding the subqueue edit form from the Nodequeue module, and I need to replace the title with a text field and use a custom theme function (overriding theme_form_element) for the textfield. I've registered my theme function with hook_theme: /** * Implementation of hook_theme */ function mymodule_theme() { return array( 'mymodule_subqueue_title' => array( 'arguments' => array($element => NULL, $value => NULL), ), ); } And then call it in my hook_form_alter" $form[$item->nid]['item_title'] = array( '#default_value' => $item->title, '#type' => 'textfield', '#size' => 10, '#maxlength' => 50, '#theme' => 'mymodule_subqueue_title', ); and define my function: function theme_mymodule_subqueue_title($element, $value) { The problem I'm getting is this error message: Missing argument 2 for theme_mymodule_subqueue_title() in .../sites/all/modules/custom/feature_package/mymodule.module on line 450. I'm guessing the problem is in how I define my arguments in hook_theme. Is that what I'm doing wrong, or is it something else? Thanks, Steve
It seems like you're touching on a relatively common feature for Nodequeue: Displaying fields from the nodes while changing the subqueue order. 3rd from the top of the Nodequeue issue queue is http://drupal.org/node/299111, which has an example from one developer that might be helpful if it's applicable to Nodequeue 6.x. It's probably easier easier to just theme the whole nodequeue_arrange_subqueue_form (we have theme_nodequeue_arrange_subqueue_form) and tweak the presentation of this field there, since much of the node object is available as part of the form. Ultimately though I think the best and most re-usable solution for your apparent end goal is what's proposed at http://drupal.org/node/568100 -- Implementing the Nodequeue ordering interface as a Views style plugin. Then we could display any field with Views support and non-developers could customize the interface for their use case (photo gallery, album mp3 track listing, etc). For the question about how #theme works, it might be helpful to checkout drupal_render(), which checks for $element['theme'], print out the lone argument passed to your custom theme function, and/or see http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html.... Cheers, Ezra On Mon, Dec 7, 2009 at 4:06 PM, Steve Edwards <killshot91@comcast.net> wrote:
I need to replace the title with a text field and use a custom theme function
Ezra Barnett Gildesgame | http://growingventuresolutions.com | http://ezra-g.com
Actually, I have everything working as I need it for my required functionality, except for the display of the title as an editable text field. I can save the data in my table and reorder the items using the default nodequeue functionality just fine; it's just the display of the field as a textfield which is causing the problem (see http://drupal.org/node/653574 for details). My reason for trying to use a #theme function for this field was that it appears that the div that is put around the form item in theme_form_item (being called through hook_form_alter) was what was causing the display problem, so I was going to remove it by overriding theme_form_item for that field. I don't think overriding theme_nodequeue_arrange_subqueue_form would work, since the div that is causing the problem is introduced in hook_form_alter. Unless I change the field type in there.... Hmmm... All I need is to get the display of the field working properly; everything else is working as I need it. I'm so close I can taste it... Thanks. Steve Ezra B. Gildesgame wrote:
It seems like you're touching on a relatively common feature for Nodequeue: Displaying fields from the nodes while changing the subqueue order.
3rd from the top of the Nodequeue issue queue is http://drupal.org/node/299111, which has an example from one developer that might be helpful if it's applicable to Nodequeue 6.x. It's probably easier easier to just theme the whole nodequeue_arrange_subqueue_form (we have theme_nodequeue_arrange_subqueue_form) and tweak the presentation of this field there, since much of the node object is available as part of the form.
Ultimately though I think the best and most re-usable solution for your apparent end goal is what's proposed at http://drupal.org/node/568100 -- Implementing the Nodequeue ordering interface as a Views style plugin. Then we could display any field with Views support and non-developers could customize the interface for their use case (photo gallery, album mp3 track listing, etc).
For the question about how #theme works, it might be helpful to checkout drupal_render(), which checks for $element['theme'], print out the lone argument passed to your custom theme function, and/or see http://api.drupal.org/api/drupal/developer--topics--forms_api_reference.html....
Cheers,
Ezra
On Mon, Dec 7, 2009 at 4:06 PM, Steve Edwards <killshot91@comcast.net> wrote:
I need to replace the title with a text field and use a custom theme function
Ezra Barnett Gildesgame | http://growingventuresolutions.com | http://ezra-g.com
Steve Edwards wrote:
In a module I'm creating, I'm embedding the subqueue edit form from the Nodequeue module, and I need to replace the title with a text field and use a custom theme function (overriding theme_form_element) for the textfield. I've registered my theme function with hook_theme:
/** * Implementation of hook_theme */ function mymodule_theme() { return array( 'mymodule_subqueue_title' => array( 'arguments' => array($element => NULL, $value => NULL), ), ); }
The #theme command only sends one argument, the $element, There is no $value. (Not even a Zuul)
participants (3)
-
Earl Miles -
Ezra B. Gildesgame -
Steve Edwards