I'm trying to render a simple form element without the accompanying tags and other drupal goodness (validation, etc). Is it possible to render a form element using form api methodology but without running it through drupal_get_form?
2 Answers
I have never done this, I don't see why anyone would need it, and I cannot recommend this approach, but... you can try to define a form element by digging up the defaults, adding some properties and passing it to render().
In code, that would look something like this:
$element = element_info('textfield');
$element['#title'] = 'Type something';
$output = render($element);
Which results in:
<div class="form-item form-type-textfield">
<label>Type something </label>
<input type="text" size="60" maxlength="128" class="form-text" />
</div>
This seems to work for simple form elements like textfield. It will surely break for more complex types like checkboxes or date fields. Hope that helps.
You can embed a for in a template file for instance with drupal_render_form() in D6 or drupal_render_children() in D7. See this community issue.
You will still have to get the FAPI array somehow, you usually still use drupal_get_form() for getting the $form
array.