0

I have created a a content type and I am using it as a registration form to be created by anonymous users.

When I create a field with type of boolean> single on/off checkbox for my terms and conditions (where it will display the terms and they will be required to check the single checkbox if they agree).

My problem is i want to add another text field for this particular field type in node form for me to put in the text for terms and conditions.

There is a help text box there which i can use, but i used it to display tooltips.

What is the best way to add another text field to boolean type field in node form?

1

You could implement hook_form_alter() and add a suffix or prefix to your field. The suffix and prefix may contain html.

    $form['terms'] = array(
      '#prefix' => '<div class="my-class">Something before the field</div>',
      '#suffix' => '<div class="my-class">Something after the field</div>',
    );

For a detailed instruction how to write a module that implements hook form alter see this blog post.

There is also a module that can add markup widgets to forms. Checkout Markup.

3
  • I am quite new to using hook_form_alter. Do i need to copy this code and paste it inside template.php? I just want to add another texfield to boolean field type in node form? Thanks – ARGO Aug 28 '12 at 9:58
  • Unfortunately I cannot use MArkup because I have conditional field set into this field type. But thanks this module will become very handy – ARGO Aug 28 '12 at 9:59
  • I've updated my answer. – Pontus Nilsson Aug 28 '12 at 11:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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