Forums

Can I print the results of a Checkbox Group within a <ul> HTML element?

entumas 09 Aug, 2016
Hi!

Can I print the results of a Checkbox Group within a <ul> HTML element?
How can I do it?

Thanks!
GreyHead 09 Aug, 2016
1 Likes
Hi entumas,

If you use a Handle Arrays action you will get a list of entries, setting the separator to <br /> will make this into a very basic list. If you want an HTML list you can use code like this:
<?php
if ( !empty($form->data['checkbox_group_name']) && count($form->data['checkbox_group_name']) > 0 ) {
  echo '<ul>';
  foreach ( $form->data['checkbox_group_name'] as $v ) {
    echo "<li>{$v}</li>";
  }
  echo '</ul>';
}
?>
Do not use the Handle Arrays action before this code is run.

Bob
entumas 09 Aug, 2016
Gives me an error!😟
Invalid argument supplied for foreach()
GreyHead 09 Aug, 2016
1 Likes
Hi entumas,

What exactly is the code you are testing?

Bob
entumas 09 Aug, 2016
Ups! I have already deleted!
Basically I copied yours and I replaced the field name (checkbox_group_name => modul_cursos_1).
This I have done in the body of e-mail
GreyHead 09 Aug, 2016
Hi entumas,

Possibly you had a Handle Arrays action before the Email action so that there was no longer an array in the form data,

Bob
This topic is locked and no more replies can be posted.