ooh form with template

Help
2004-05-07
2004-05-10
  • hello world

    hello world - 2004-05-07

    Hi,

    I am new to phplib just wondering is this correct way to use the ooh form with template.

    require_once("./config/config.php");
    $perm->check("user");

    $tpl = new Template;
    $tpl->set_file("contact_form", "contact_form.html");

    $tpl->set_block("contact_form", "contact_form_block", "tpl_contact_form");
    $tpl->set_var(array("pagetitle" => "Contact",
                        "title" => "<b>Contact</b>"));   
    $f = new form;

    $f->add_element(array("type"=>'text',
                          "name"=>'name',
                          "size"=>'60',
                          "valid_regex"=>'^[a-z]*$',
                          "valid_e"=>'Letters only',
                          "icase"=>1,
                          "value"=>$name));

    $f->add_element(array("type"=>'text',
                          "name"=>'company',
                          "size"=>'40',
                          "value"=>$company));

    $f->add_element(array("type"=>'text',
                          "name"=>'jobtitle',
                          "size"=>'40',
                          "value"=>$jobtitle));

    $f->add_element(array("type"=>'text',
                          "name"=>'ic',
                          "size"=>'15',
                          "value"=>$ic));

    $f->add_element(array("type"=>'text',
                          "name"=>'workphone',
                          "size"=>'15',
                          "value"=>$workphone));

    $f->add_element(array("type"=>'text',
                          "name"=>'workext',
                          "size"=>'5',
                          "value"=>$workext));

    $f->add_element(array("type"=>'text',
                          "name"=>'mobilephone',
                          "size"=>'15',
                          "value"=>$mobilephone));

    $f->add_element(array("type"=>'text',
                          "name"=>'faxnumber',
                          "size"=>'15',
                          "value"=>$faxnumber));

    $f->add_element(array("type"=>'text',
                          "name"=>'pagernumber',
                          "size"=>'15',
                          "value"=>$pagernumber));

    $f->add_element(array("type"=>'text',
                          "name"=>'emailaddress',
                          "size"=>'50',
                          "value"=>$emailaddress));

    if ($submitname)                 // Is there data to process?
      if ($err = $f->validate()) {   // Is the data valid?
        echo $err;                   // No; Display error
        $f->load_defaults();  // Load form with submitted data
          }
      else {
        /* Process data */           // Data ok; Do something with it
          }

    $form = "ContactForm";
    $f->get_start($jvsname,$method,$action, $target, $form);                  // Start displaying form

    $tpl->set_var(array("name" => $f->get_element('name'),
                "company" => $f->get_element('company'),
                "jobtitle" => $f->get_element('jobtitle'),
                "ic" => $f->get_element('ic'),
                "workphone" => $f->get_element('workphone'),
                "workext" => $f->get_element('workext'),
                "mobilephone" => $f->get_element('mobilephone'),
                "faxnumber" => $f->get_element('faxnumber'),
                "pagernumber" => $f->get_element('pagernumber'),
                "emailaddress" => $f->get_element('emailaddress')));
    $f->get_finish();
    $tpl->parse("tpl_contact_form", "contact_form_block", true);
    $tpl->pparse("OUTPUT", "contact_form");
    page_close();
    ?>

     
    • hello world

      hello world - 2004-05-10

      $f->get_start($jvsname,$method,$action, $target, $form); // Start displaying form

      are the above work in a template environment

       

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks