php - How to add static html markup to a CiviCRM form


I have CiviCRM 4.4.6 + Drupal 7 and i alter one of CiviCRM's forms.

Insidehook_civicrm_buildForm(), i try to:

form->addElement('html', 'statichtml', '<div>aa</div>');
$template =& CRM_Core_Smarty::singleton();
$bhfe = $template->get_template_vars('beginHookFormElements');
if (!$bhfe) {
  $bhfe = array();
$bhfe[] = 'statichtml';
$form->assign('beginHookFormElements', $bhfe);

If i use it with 'text' element type, it works correctly. This way nothing is rendered, but an empty additionaltr is added. How to use this type of element correctly?



Solution: Here is the explanation. The element type should bestatic, nothtml and the above code starts to work.

People are also looking for solutions to the problem: php - Symfony2's AccessDeniedHandlerInterface to automatically redirect unauthorized users


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.