Support » Plugins » Cforms 6- Custom : Creating dynamic forms (select box autofill)

  • Resolved matinciel



    I’m using WordPress 2.6.3 and CformsII 9.3. And I want to create a selectbox in one of my forms which will be filled with an database.

    I’ve read the paragraph 6 of the help file (Creating dynamic forms) but I can’t understand where to put the example code at the end of the paragraph in order to test it.

    If someone could tell me what to do with this would be so nice.

    above the example code which is in the help :

      $fields = array();

      $formdata = array(
      array(‘Votre nom|Votre nom’,’textfield’,0,1,0,1,0),
      array(‘Votre email’,’textfield’,0,0,1,0,0),
      array(‘Votre message’,’textarea’,0,0,0,0,0)

      foreach ( $formdata as $field ) {
      $fields[‘label’][$i] = $field[0];
      $fields[‘type’][$i] = $field[1];
      $fields[‘isdisabled’][$i] = $field[2];
      $fields[‘isreq’][$i] = $field[3];
      $fields[‘isemail’][$i] = $field[4];
      $fields[‘isclear’][$i] = $field[5];
      $fields[‘isreadonly’][$i++] = $field[6];

      insert_custom_cform($fields,”); //call the default forms with two new fields

Viewing 2 replies - 1 through 2 (of 2 total)
  • I’ve got an answer from Olivier, the author of this plugin.

    The complete code block usually goes into the PHP page template and is being execute on a particular page ID (usually your contact page).
    So you need to add an IF clause around this code block to only being executed when being on that contact page of yours.

    General info for page :

    Specific info:
    1- go in /wordpress/wp-content/themes/Your_Theme/
    2- copy the page.php
    3- rename the copy ex :test.php
    4- Edit the copy
    5- add this at the beginning

    Template Name: test

    6-just after copy the example code (or your custom code)
    note : – add the “<?php” at the beginning and the “?>” at the end without the quotes
    – DON’T INSERT this line : insert_custom_cforms…
    7- place the line:
    insert_custom_cform($fields,''); //call the default forms with two new fields
    in the <div class="entry"> of the test file to get the forms in the core message
    8- save the test.php file
    10- Create a new page in wordpress as normal, just select the test.php template you’ve just create as template

    WordPress can be configured to use different Page Templates for different Pages. Toward the bottom of the Write > Page administration panel (or on the sidebar, depending on which version of WordPress you are using) is a drop-down labeled “Page Template.” From there you can select which Template will be used when displaying this particular Page.

    9- view results :-p

    PS: i am an autodidact of coding, maybe it’s not the standard way to do this, please do not hesitate to correct any mistake you found.

    PS2: For french speaker i think there is a mistake in the translation of the second example in the french version at this date, you shoul use the non translated text from olivier.

    Hi Manticiel,
    thanks for posting Olivier’s answer. This is exactly what I needed to know.

    I think Cforms is a fantastic plugin (one of the best), and I can’t believe Olivier is putting so much effort in it.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Cforms 6- Custom : Creating dynamic forms (select box autofill)’ is closed to new replies.