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

Please use our new MachForm Community Forum instead.

MachForm Community Forums » MachForm 2

Default Values in Price or Date Fields


  1. rscott7706
    Member

    Hi folks,

    I have some forms that are sectioned. If a client has one need, they fill in a particular section. If another need, they skip to another section. As I am also using required fields in the different sections, this creates a problem.

    I have several fields that should be required, such as date and price fields. But, if I make them required, the clients then would be forced to populate fields in sections not applicable to them. (Price or Date fields).

    Is there a way I can make all date or price fields pre-populate with a value? For date fields, a simple 1/1/2008 would be fine (or what ever 01/01/2008, etc.) and for price, a simple 1 dollar would be fine.

    If not is there any way to get the fields (as I build them) to except some default value?

    Thanks!!

    Ron

    Posted 15 years ago #
  2. redityo

    Hi Ron,

    What the condition to customer should fill the date and price field or not ?


    MachForm Support

    Posted 15 years ago #
  3. Saghalie
    Pro Member

    For default values, just fill in the "Default Value" section under field properties.

    I would suggest putting in there "Not Applicable" or just "NA".

    Saghalie.

    Posted 15 years ago #
  4. rscott7706
    Member

    redityo

    I am not good at explaining sometimes, there will be sections in the form that get filled out if one condition exists and another section filled out if another situation exists - and they both will have a date field. So, in order to legitimately instruct the client to "Skip" a section, I must pre-populate all the date fields.

    So, both sections contain a date field for instance. They both need to be populated with default values so, when the form is submitted it will pass the "required" validation. One field gets re-written with to proper date for the section applicable to the client, the other remains.

    I hope this makes sense.

    Saghalie
    I do find that telephone fields have a "default" option, so this is solved, but date fields do not have a "default" option. Hence my situation.

    Thanks All - I hope explained that better.

    Here is a link that may help: http://www.masterliens.biz/machform/view.php?id=4

    Ron

    Posted 15 years ago #
  5. redityo

    Hi Ron,

    You can set default value for date element by edit "inludes/view-functions.php" and add these code to line 358.

    $element->populated_value['element_'.$element->id.'_1']['default_value'] = "01";
    $element->populated_value['element_'.$element->id.'_2']['default_value'] = "01";
    $element->populated_value['element_'.$element->id.'_3']['default_value'] = "1990";

    it should give your date field with 01/01/1990


    MachForm Support

    Posted 15 years ago #
  6. rscott7706
    Member

    Thanks redityo - I will try to look at doing this tonight or tomorrow.

    Thanks for the tip!!

    Ron

    Posted 15 years ago #
  7. komita
    Member

    I want a default value for the "price" field and do not see that I can set that. I can see it in number, but not price.

    Posted 15 years ago #
  8. yuniar

    Let say you have a form with id number=27 and your price field is having id=4, and would like to put $34.99 as default value for your price field.

    Edit includes/view-functions.php file, around line 825 you should find this code:

    function display_money($element){

    under that line, insert this code:

    if($_REQUEST['id'] == 27 && $element->id == 4){
    	if(empty($element->populated_value['element_'.$element->id.'_1']['default_value'])){
    		$element->populated_value['element_'.$element->id.'_1']['default_value'] = 34;
    	}
    
    	if(empty($element->populated_value['element_'.$element->id.'_2']['default_value'])){
    		$element->populated_value['element_'.$element->id.'_2']['default_value'] = 99;
    	}
    }

    that would set the default value for your price field.


    MachForm Founder

    Posted 15 years ago #

RSS feed for this topic

Reply