By knight42 on
hey all
can please help me, I have a custom node submit form for creating content, all is good with it and have worked out how to put in the various fields, but I cant get the categories to show up at all. Am using this code
<?php print drupal_render($form['group_car_details']['field_priceone']);
?> To list the fields, but for taxonomy/categories I have no idea. Does anyone know how to call them?
thanks
Comments
...
Try
print drupal_render($form['taxonomy']);excellent, that works. Would
excellent, that works. Would you have any idea how to only print out one vocab (vocab/2)
I have several different vocabs and wanted them spaced out around the form rather than grouped together. I tried
and
But couldnt get either to work. Any ideas? Thanks
...
I believe this should have worked.
Note the once you drupal_render() an element, this element and its descendants are marked as "printed". In other words, once you drupal_render($form['taxonomy']), you can no longer drupal_render($form['taxonomy'][2]). You must drupal_render($form['taxonomy'][2]) first.
Thanks for the reply, still
Thanks for the reply, still cant get it to work, I have the "print the rest of the form" PHP at the very end of the form (mainly to print the submit button) but have nothing else before it, but it still refuses to print! Any ideas
As another question on the
As another question on the same topic.....
How do you print just the Submit button on its own?
At the moment I am using
<?php print drupal_render($form); ?>Which prints out everything missed in the form, problem is, it prints out my group titles as well as they havent been printed. Any ideas
...
Printing _just_ the 'Submit' button will make the form fail. For FAPI to operate correctly you need to print at least one special hidden form variable:
$form['form_id']. And there's also$form['token']. In other words, it's a very good thing to always finish withprint drupal_render($form), unless you have a good understanding of FAPI.There are several ways to omit an element from the output.
1. You can call
drupal_render($form['element']);--without printing, or returning, the result.2. You can remove the element from the form structure:
unset($form['element']);.3. You can disable access to it:
$form['element']['#access'] = FALSE;.(It's OK to print a sub-element but to omit the parent element. (In other words, you can safely print $form['taxonomy'][2] and then delete $form['taxonomy'].))
...
I've just checked this.
$output .= drupal_render($form['taxonomy'][2]);does work for me. I don't know why it doesn't work for you, so I need to see the whole code. (That you doprint()instead ofreturn $outputisn't an error: it depends on where you do your theming --which I don't know yet (BTW, your shouldprint(), notprint_r()--butprint_r()too should work so that's not the cause of our bug).)Perhaps the vocab ID isn't '2'?
Sweet! Thanks for that
Sweet! Thanks for that Mooffie....Ive done a bit of a work around and kept all the vocabs together in one group rather than splitting them up. Works well actually, am thinking this may be easier to keep them all together as there all free tagging categories, so to keep them all together means I only need to explain it once!
The category titles no longer print so im really happy with that. Thanks for all your help you have been really cool.....oh and on a completely different note, I see your from Israel, can I just say as an Englishman, thanks very much for the win on Saturday night at football, you cant imagine how happy that made about 60 million English !!!!!!!!
...
rofl :-)
and yeah no more talk about
and yeah no more talk about football now! Its banned on here!
just thought id let you know i finally cracked it!!!! I used
<?php print drupal_render($form['taxonomy'][2]); ?>And it works! Before I was closing the question marks twice at the end!! and I got rid of the print_r as you said as well and it all works, so thanks again! Shame about the football though, we all like rugby over here now!
Ok may have spoken too soon
Ok may have spoken too soon on that!
It works fine if the vocab is working from a list, if you use free tagging (which about 3/4 of my vocabs are) it just breaks and sends them back to the bottom again.
Its the free tagging thats doing it, have tested it by switching it on and off on a certan vocab. Any ideas?
...
For free-tagging vocabs, do:
print drupal_render($form['taxonomy']['tags'][2]);('2' is the vocb ID.)
Moofie your a star! Thanks
Moofie your a star! Thanks very much!!!!!