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

standard vs advance form code


  1. texags2008
    Member

    I am passing session variables (username and email) to automatically set the default values for two elements.

    Is there any reason this process works when using the standard form code and not via the advanced? And yes I am doing the session_start().

    tia

    Posted 15 years ago #
  2. redityo

    Hi Tia,

    Why you don't use "default value" options when edit the form rather than create a custom code ? I think it's much easier.


    MachForm Support

    Posted 15 years ago #
  3. texags2008
    Member

    This is on a wordpress blog. I am auto populating a single line text and an email element with the info for the logged in user.

    Are you saying when building the form for the default value I can just put the variable in there? I am doing it this way because that is how yall told me a year ago!

    Posted 15 years ago #
  4. texags2008
    Member

    Here is my previous thread. I never got the variables working using the advance code, only through the standard.

    [url]http://www.appnitro.com/forums/topic/session-variable-as-default-value-in-admin-only-fields?replies=6[/url]

    Posted 15 years ago #
  5. texags2008
    Member

    in view-functions if i place

    echo $_REQUEST['id'];

    it will print the form ID for a form added the standard iframe way but nothing when inserted the advanced php way. is there another variable used when added via php which would distinguish which form it is?

    as a temp fix, since i only need\have one form up at a time, i removed the logic of determining which form it is and only care about which element it is.

    Posted 15 years ago #
  6. redityo

    Ah .. I see, advance embed code do not recognize "$_REQUEST['id']" code indeed. You need to determine what is your form id with custom code. To do so, you can use a session variable, you already have advance embed code like this :

    <?php
    	require("C:/path/machform.php");
    	$mf_param['form_id'] = 1;
    	$mf_param['base_path'] = 'http://yourdomain.com/machform/';
    	display_machform($mf_param);
    ?>

    then, add a session variable to be like this

    <?php
    	require("C:/path/machform.php");
    	$mf_param['form_id'] = 1;
    	$_SESSION['sess_form_id'] = 1;
    	$mf_param['base_path'] = 'http://yourdomain.com/machform/';
    	display_machform($mf_param);
    ?>

    after that, add an "or" condition to your "view-function.php" like this

    if(($_REQUEST['id'] == 1 || $_SESSION['sess_form_id'] == 1 ) && ($element->id == 3)){
    $element->default_value = $_SESSION['your_session_var'];
    }

    MachForm Support

    Posted 15 years ago #
  7. texags2008
    Member

    awesome. will try when i get home from work. thanks.

    Posted 15 years ago #

RSS feed for this topic

Reply