Appnitro Software Forums » MachForm 2

Forced and hidden value


  1. Jos
    Member

    Hi,

    Two questions. I guess I saw a topic about a forced value but can't find it anymore. A form should only be submitted if the value for a field is equal to a predefined value.

    Second problem: I have a dropdown with, for example, the following options:
    Answer A
    Answer B
    Answer C

    When the value is e-mailed to me I don't want to see this exact value, but with some hidden code, like:

    A1-Answer A
    A2-Answer B
    A3-Answer C

    For each option an other "prefix". In HTML this isn't so hard.. but with Machform I don't know what to edit..

    Any ideas how I should solve this problems?

    Thanks in advance!

    Posted 2 years ago #
  2. redityo

    Hi,

    For your first question, I'm not sure where you want to put the validation. However let's make an example, let's say you need a user to fill a number field value greater than 10, otherwise it'll show an error. To do this, you need to edit "includes/post-functions.php" file, go to around line 238 and you'll see these code :

    $validation_result = validate_element($target_input,$rules);

    then put these code exactly bellow that line

    if ($form_id == 7 && $element_id == 3) {
    	if ($element_data < 10) {
    		$error_elements[$element_id] = "You need to input a number greater that 10";
    	}
    }

    That code will work for form 7 with number field id 3, you need to change those ID's with yours.

    And for your second questions, you need to edit "includes/helper-functions.php" to set drop down prefix in mail notification. Go to around line 355 and you'll see this code :

    $email_body .= "<tr {$row_style}>\n";

    then put these code exactly above that line

    if ($data['element_type'] == 'select' &&  $data['element_id'] == 2 && $form_id == 7) {
    	switch($data['value']) {
    		case 'First option':
    			$data['value'] = 'A1 - ' . $data['value'];
    			break;
    		case 'Second option':
    			$data['value'] = 'A2 - ' . $data['value'];
    			break;
    		case 'Third option':
    			$data['value'] = 'A3 - ' . $data['value'];
    			break;
    	}
    }

    Those code will add a prefix based on your drop down selection and don't forget to change the id's also


    MachForm Support

    Posted 2 years ago #

RSS feed for this topic

Reply