I have a requirement in drupal. In this i have a content type 'sports' and created some custom fields of type dropdown, checkbox and file.

I want to get the custom field with its type as html in front end.

Example In dropdown i have

<options value="15">Cricket</options>
<options value="16">Football</options>
<options value="16">Basketball</options>

I want the same in frontend to display as html

  • What is the reason you want to have that options in frontend? You had a form to contains that options?
    – Jimmy Ko
    Nov 18, 2016 at 10:33
  • Yes i am creating front end form to give as api to create node Nov 18, 2016 at 10:35
  • Are you using API form?
    – Jimmy Ko
    Nov 18, 2016 at 10:36
  • exactly you are right! Nov 18, 2016 at 10:36
  • 1
    ok thanks for your help and i will look at that.:) Nov 18, 2016 at 12:07

1 Answer 1


Finally i found what i want actually in front end.

The below code displays the form that it has on backend.

This form is for 'sports' content type. This wil bring all fields with its widget wherever we calling.

module_load_include('inc', 'node', 'node.pages'); 
$form = node_add('sports');
print drupal_render($form);
  • Please edit your answer to explain the code you include in this answer. That will reduce the risk the answer gets deleted (via moderation) because it may be perceived as a low quality answer. Nov 18, 2016 at 11:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.