Form Builder CSS class
  • I see there is a "class" option for the form builder however it does not seem to be working. I have it formatted as:

    $fields['website_design'] = array('type' => 'checkbox', 'options' => array('yes' => 'yes', 'no' => 'no'), 'class' => 'formtest');

    Neither the label nor the checkbox (or the surrounding div) have the formtest css class set even though the above has been set.
  • I also tried the 'before_html' => 'div class="formtest"' (i did use < and > in the actual code, these forums don't let you display html), however it is automatically placing a closing tag as well so this doesn't really help me. I would need it to not automatically generate the closing div tag so I can place it further down in an after_html option.
  • Try using the type of "enum" instead of "checkbox" which will give you radio buttons. Is this using 0.93 or the 1.0 beta branch?
  • Sorry for including the yes/no array in the code above but I really am trying to do a checkbox. Even when formatted as $fields['website_design'] = array('type' => 'checkbox', 'class' => 'formtest'); it still doesn't work. It does however let me aply the class option to fields with no type defined (regular text fields). This is with 0.93.
  • That's a bug in 0.93 and should be fixed in 1.0 branch. To fix it, try adding the following to the Form_builder class on line 1334:
    'class' => $params['class']
  • That fixed it, thanks. Now, is it possible with the before_html and after_html options to not have it automatically create a closing div tag when an opening div tag is used?
  • Are you sure it is rendering the closing div tag or is that the Inspector in the browser displaying it perhaps because it was an unclosed tag?
  • I inspected the source and it seems like indeed that is what it is doing. It's displaying it differently in the inspector than in the actual source code. Thanks again. My final question since it ties in with this is is there a way to change the order in which the label and checkbox appear (I want the label on the right) on the fly or would the Form_builder class need modification. I don't want the label to always appear on the right, only for these particular checkboxes.
  • In 0.93 you can't really do it unless you add a " " (an empty space) for the label value and then do an after_html for the field with your label. In 1.0 you can pass a "display_label" boolean parameter to the field to hide it.
  • I'll check out 1.0. I really appreciate the continual support you provide for this CMS. Thanks.
  • No problem. Be sure to download and install the user guide module for 1.0 beta. The Form_builder class was overhauled a bit as well as a bunch of new features and bug fixes.

    Other modules (e.g. blog, backup, cronjobs, etc) are separated out but can be individually pulled down and installed:

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!