checkboxes revisited

I visited this thread before posting here:  HERE

This problem persists, exactly as above, with 7.1.5, and the template being used does NOT change anything (therefore not being affected by 3rd party .css) as it happens with untouched default templates.

On my multi-select checkboxes, Im getting:

country
p
op-rock
r
&b
variety
dance and DJ
etc...

BxBaseFormView.php:

        if (isset($aInput['values']) and is_array($aInput['values'])) {

           if (count($aInput['values']) > 3 && $sDivider == ' ')  <--This number 'changed' has ZERO affect on the display.
               $sDivider = '<br />';  <---changed to '----' (for testing purposes)

Now getting, and on a single line:

Preferred Music:
 
country  ---- pop-rock  ---- R&B  ---- variety  ---- dance and DJ  ----etc...

 

 So.. for what ever reason, the problem lies in the fact that its not waiting for every 3rd line, its placing $sDivider directly after EVERY item.

And that's why its showing everything in a single column, because $sDivider is placing '<br />' after EACH item.

Can someone PLEASE weigh in here?

 

 

 

 

Quote · 19 Mar 2015

Hello

It's a default behaviour. If you have less than 3 items then they should be displayed in one line. But if you have more than 3 they will be disaplayed in one column. If you want to have 3 per line then try to use the following code.

       if (isset($aInput['values']) and is_array($aInput['values'])) {
          //if (count($aInput['values']) > 3 && $sDivider == ' ')               <--- commented
          //    $sDivider = '<br />';                                                           <--- commented
          // generate complex input using simple standard inputs
          $i = 1;
          foreach ($aInput['values'] as $sValue => $sLabel) {
               $sDivider = ' ';
               if($i % 3 == 0)
                   $sDivider = '<br />';
              // create new simple input
              $aNewInput = array(
                  'type' => 'checkbox',
                  'name' => $aInput['name'] . '[]',
                  'value' => $sValue,
                  'checked' => in_array($sValue, $aCurValues),
                  'label' => $sLabel,
              );
              $sNewInput  = $this->genInput($aNewInput);
              // attach new input to complex
              $sOptions .= ($sNewInput . $sDivider);
              $i++;
          }
      }

Best Regards AntonLV - http://www.boonex.com/market/posts/AntonLV
Quote · 19 Mar 2015

Anton! That worked! Im very appreciative! Smile

If I am not pressing my luck, may I ask if the spacing between each can be controlled as well? Right now, it looks quite jumbled, as you may see..
Even if I only have 2 per line, so that the checkboxes can line up, that would still be just fine.. 

Regardless of a followup answer, thank you again!!

Quote · 19 Mar 2015

Hello 

If I am not pressing my luck, may I ask if the spacing between each can be controlled as well? Right now, it looks quite jumbled, as you may see..
Even if I only have 2 per line, so that the checkboxes can line up, that would still be just fine.. 
Regardless of a followup answer, thank you again!!

You are welcome! :) 
Yes, I see the problem. It appears because all checkboxes have labels with different sizes and they divided with common spaces. If you want to have a good colum based structure you need to update the code that it generates a table. Wrap each checkbox in <td> and create lines using <tr> instead of the <br />. Don't forget to wrap the generated code in <TABLE> tag. I think it should work.

Best Regards AntonLV - http://www.boonex.com/market/posts/AntonLV
Quote · 20 Mar 2015

Hello everyone - I mananged to my check boxes in 4 columns by following Anton's instructions. Thank you SO much Anton for taking the time to post thoses instructions.

Are there any further instructions on how to do the next stage - update the code so it generates a table? My checkboxes are not in neat vertical lines either and I'd love to get this resolved.

Any help will be hugely appreciated...

J

Quote · 19 Aug 2015
 
 
Below is the legacy version of the Boonex site, maintained for Dolphin.Pro 7.x support.
The new Dolphin solution is powered by UNA Community Management System.