Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter thatdiegokid

    (@thatdiegokid)

    wiped userscripts.js
    and modified formelements/formelements.php
    to this

    function fe_getInputHTML($elementDef){
    	global $wpdb;
    	$query_results = $wpdb->get_results('SELECT required FROM wp_fm_items WHERE <code>unique_name</code> = "'.$elementDef['attributes']['name'].'"');
    
    	$required = "";
    	if ($query_results[0]->required == '1'){
    		$required = " required";
    	}
    
    	$str = "<input type=\"".$elementDef['type']."\" ".fe_getAttributeString($elementDef['attributes']).$required.">";
    
    	return $str;
    }

    I normally wouldn’t recommend modifying the plugin like this since any changes will get overwritten with an update, but personally, I needed to get this functionality in now.

    Ah, are you using the list (I just found that, and have been backwards engineering my way through this plugin).

    The separator seems to be hardcoded to a
    tag.
    I had to manually change it in the plugins folder under /types/lists.php the instances of 'separator' => '<br>', to 'separator' => '</li><li>',

    then in
    formelements/formelements.php, inside function fe_getCheckboxListHTML, I changed
    $str = implode($elementDef['separator'],$arr);

    to

    $str = '<ul><li>'.implode($elementDef['separator'],$arr).'</li></ul>';

    to produce a list, that you can then style with CSS!

    In a custom template, I created something like this to deal with exactly that, since I needed my checkboxes grouped in a div.
    Seems like it’d only work if you have one grouping of checkboxes, but it’s a start and just built this an hour ago.

    global $wpdb;
    $form_id = fm_form_ID();
    $form_shortcode = preg_replace('/fm-/','',$form_id);
    $elements = $wpdb->get_results( 'SELECT COUNT( ID ) AS count
    FROM wp_fm_items
    WHERE wp_fm_items.ID = (
    SELECT ID
    FROM wp_fm_forms
    WHERE shortcode = "'.$form_shortcode.'" )
    AND wp_fm_items.type = "checkbox"' );
    
    $chck_num = $elements[0]->count;
    
    while(fm_form_have_items()): fm_form_the_item();
    
    if (fm_form_item_type() == 'checkbox'){
    if ($chck_count == 0){ ?>
    <div class="form-group">
    <label class="radio-inline form-wrap__label--bold"> Group Label</label>
    <?php } ?>
    <label class="checkbox-inline" for="<?php echo fm_form_the_nickname();?>">
    <?php echo fm_form_the_input(); ?>
    <?php echo fm_form_the_label(); ?></label>
    <?php
    $chck_count++;
    if ((int)$chck_count == (int)$chck_num ) { echo '</div>'; }
    } else {?>
    <div class="form-group" id="<?php echo fm_form_the_nickname();?>">
    <label for="<?php echo fm_form_the_nickname();?>" class="hide"><?php echo fm_form_the_label(); ?></label>
    <?php echo fm_form_the_input(); ?>
    </div>
    <?php } endwhile; ?>

    Is there a checkbox grouping function that I’m not aware of? Only started digging into this plugin today…

Viewing 4 replies - 1 through 4 (of 4 total)