当前位置: 首页>>代码示例>>PHP>>正文


PHP YDForm::toHtml方法代码示例

本文整理汇总了PHP中YDForm::toHtml方法的典型用法代码示例。如果您正苦于以下问题:PHP YDForm::toHtml方法的具体用法?PHP YDForm::toHtml怎么用?PHP YDForm::toHtml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在YDForm的用法示例。


在下文中一共展示了YDForm::toHtml方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionDefault

 function actionDefault()
 {
     // Mark the form as not valid
     $this->template->assign('formValid', false);
     // Create the form
     $form = new YDForm('uploadForm');
     // Add the elements
     $file =& $form->addElement('file', 'file1', 'Select a file to upload:');
     $form->addElement('submit', 'cmdSubmit', 'Send');
     // Add a rule
     $form->addRule('file1', 'uploadedfile', 'You need to select a valid file');
     //$form->addRule( 'file1', 'maxlength', 'Path can only be 8 characters', 8 );
     $form->addRule('file1', 'maxfilesize', 'Maximum filesize of 10 KB is exceeded!', 10 * 1024);
     //$form->addRule( 'file1', 'extension', 'File extension should be txt!', 'txt' );
     // Process the form
     if ($form->validate()) {
         // Move the uploaded file
         if ($file->isUploaded()) {
             // Move the upload
             $file->moveUpload('.');
             // Mark the form as valid
             $this->template->assign('formValid', true);
         }
     }
     // Add the form to the template
     $this->template->assign('form_html', $form->toHtml());
     $this->template->assignForm('form', $form);
     // Output the template
     $this->template->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:30,代码来源:fileupload.php

示例2: actionDefault

 function actionDefault()
 {
     // Mark the form as not valid
     $this->setVar('formValid', false);
     // Create the form
     $form = new YDForm('uploadForm');
     // Add the elements
     $file =& $form->addElement('file', 'file1', 'Select a file to upload:');
     $form->addElement('submit', 'cmdSubmit', 'Send');
     // Add a rule
     $form->addRule('file1', 'uploadedfile', 'You need to select a valid file');
     // Process the form
     if ($form->validate()) {
         // Move the uploaded file
         if ($file->isUploaded()) {
             $file->moveUpload('.');
         }
         // Mark the form as valid
         $this->setVar('formValid', true);
     }
     // Add the form to the template
     $this->setVar('form_html', $form->toHtml());
     $this->addForm('form', $form);
     // Output the template
     $this->outputTemplate();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:26,代码来源:fileupload.php

示例3: actionForm

 function actionForm()
 {
     // Create the form
     $form = new YDForm('form1', 'GET');
     // Add elements
     $form->addElement('text', 'txt', 'Enter text:');
     $form->addElement('submit', 'cmdSubmit', 'submit');
     // Display the form
     $this->template->assign('form', $form->toHtml());
     // Display the template
     $this->template->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:12,代码来源:form_get.php

示例4: actionDefault

 function actionDefault()
 {
     // Mark the form as not valid
     $this->template->assign('formValid', false);
     // Create the form
     $form = new YDForm('uploadForm');
     // Add the elements
     $file =& $form->addElement('file', 'file1', 'Select a file to upload:');
     $form->addElement('submit', 'cmdSubmit', 'Send');
     // Add a rule
     $form->addRule('file1', 'uploadedfile', 'You need to select a valid file');
     //$form->addRule( 'file1', 'maxlength', 'Path can only be 8 characters', 8 );
     $form->addRule('file1', 'maxfilesize', 'Maximum filesize of 1000 KB is exceeded!', 1000 * 1024);
     //$form->addRule( 'file1', 'extension', 'File extension should be txt!', 'txt' );
     // Process the form
     if ($form->validate()) {
         // Move the uploaded file
         if ($file->isUploaded()) {
             // You may fetch the name before the file hits the FS
             $temp_filename = $file->getBaseName();
             // Move the upload
             $file->moveUpload('./tmp');
             //$file->moveUpload( './tmp', 'TEST_' . $temp_filename );
             //$file->moveUpload( './tmp', md5(time()) );
             //$file->moveUpload( './tmp', md5(time()), true );
             // Mark the form as valid
             $this->template->assign('formValid', true);
             // Display file information
             $this->template->assign('filename', $file->getBaseName());
             $this->template->assign('filesize', $file->getSize());
             $this->template->assign('ext', $file->getExtension());
             $this->template->assign('path', $file->getPath());
         }
     }
     // Add the form to the template
     $this->template->assign('form_html', $form->toHtml());
     $this->template->assignForm('form', $form);
     // Output the template
     $this->template->display();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:40,代码来源:fileupload.php

示例5: actionDefault

 function actionDefault()
 {
     // Mark the form as not valid
     $this->setVar('formValid', false);
     // Create the form
     $form = new YDForm('emailForm');
     // Add the elements
     $form->addElement('text', 'email', 'Enter your email address:', array('style' => 'width: 300px;'));
     $form->addElement('submit', 'cmdSubmit', 'Send');
     // Apply a filter
     $form->addFilter('email', 'trim');
     // Add a rule
     $form->addRule('email', 'email', 'Please enter a valid email address');
     // Process the form
     if ($form->validate()) {
         // Mark the form as valid
         $this->setVar('formValid', true);
         // Parse the template for the email
         $emlTpl = new YDTemplate();
         $emlTpl->setVar('email', $form->getValue('email'));
         $body = $emlTpl->getOutput('email_template');
         // Send the email
         $eml = new YDEmail();
         $eml->setFrom('pieter@yellowduck.be', YD_FW_NAME);
         $eml->addTo($form->getValue('email'), 'Yellow Duck');
         $eml->setSubject('Hello from Pieter & Fiona!');
         $eml->setHtmlBody($body);
         $eml->addAttachment('email.tpl');
         $eml->addHtmlImage('fsimage.jpg', 'image/jpeg');
         $result = $eml->send();
         // Add the result
         $this->setVar('result', $result);
     }
     // Add the form to the template
     $this->setVar('form_html', $form->toHtml());
     $this->addForm('form', $form);
     // Output the template
     $this->outputTemplate();
 }
开发者ID:BackupTheBerlios,项目名称:ydframework-svn,代码行数:39,代码来源:email.php


注:本文中的YDForm::toHtml方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。