This forum is no longer open and is for reading/searching only.

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 4

Only have the check box selected when the actual box is clicked


  1. heatherbartolotta
    Member

    Hello,
    We have a request to NOT have the check box be selected unless the actual check box is clicked on.
    Right now it checks if the words next to the check box are clicked on.

    Is that possible?

    Thank you.

    Posted 11 years ago #
  2. heatherbartolotta
    Member

    I think I see what needs to be changed.

    The text box code looks something like this:
    input id="element_34_4" name="element_34_4" class="element checkbox" type="checkbox" value="1"/>
    <label class="choice" for="element_34_4">Virgin Islands (BVI/USVI)</label>

    If I remove:
    for="element_34_4"

    It works exactly how I want it to.

    Is there a way to remove that rendering for just one of my forms?

    Posted 11 years ago #
  3. williamansley
    Member

    @heatherbartolotta: This can be done by modifying the baseline Machform code with conditional logic based on the form ID number. Here is a completely unrelated example from a much older version of Machform, but it may help a bit. This code triggers an error if a field contains a particular value and asks the user to enter a new one.

    if ($form_id == 3 && $element_id == 21) {
    	if ($element_data == 'A00000000') {
    		$error_elements[$element_id] = "Please fill in your A#.";
    	}
    }
    Posted 11 years ago #
  4. heatherbartolotta
    Member

    What PHP page needs to be modified?

    Posted 11 years ago #
  5. yuniar

    You can edit your "includes/view-functions.php" file, search around line 1744 for this code:

    $pre_option_markup .= "<label class=\"choice\" for=\"element_{$element->id}_{$option->id}\">{$option->option}</label>\n";

    now let say you want to enable the hack for form with id number 87 only, then the code should be like this:

    if($element->form_id == 87){
      $pre_option_markup .= "<label class=\"choice\">{$option->option}</label>\n";
    }else{
      $pre_option_markup .= "<label class=\"choice\" for=\"element_{$element->id}_{$option->id}\">{$option->option}</label>\n";
    }

    MachForm Founder

    Posted 11 years ago #

RSS feed for this topic

Reply