1

I am using Drupal 7, (fairly new to module dev) here's my use case- I am trying to add a terms and conditions field directly within the user_registration screen. The Administrator sets the terms, so they have access to change the field values, but the authenticated user will not.

I am adding a custom field and when the field is loaded paragraphs, breaks, quotes are converted to html characters instead of rendering as an actual paragraph - I am assuming because the textarea isn't seen by ckeditor library? Im trying to display the field with the rendered paragraphs and breaks as this displays fine for admin users. It almost as if I need to specify rich-text

How would I do this?

function myModule_form_user_register_form_alter(&$form, &$form_state, &$form_id) {

 $form['field_agreement']['#access']=FALSE; //the default field is hidden from authenticated users

 //adding in custom field for auth users

 $form['Agreement'] = array (
  '#type' => 'textarea',
  '#title' => t('Terms & Conditions'),
  '#default_value' => $form['field_venue_agreement']['und']['0']['#default_value'],
  '#weight' => '10',
  '#description' => t('You must agree to our terms each time a new user is added'),
  '#disabled' => TRUE,
);

}
0

I didn't find the answer I wanted to find, but after careful examination of the form api, I discovered markup and it led me down the path of fooling the end user into thinking it looked like a field with some css manipulation. This is working for me

$form['Venue Agreement'] = array (
 ['0']['#default_value'],
  '#weight' => '10',
  '#markup' => $form['field_venue_agreement']['und'['0']['#default_value'],
  '#prefix' => '<div class="form_input">',
  '#suffix'=> '</div>',
);

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.