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();
 }
 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();
 }
Exemplo n.º 3
0
 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();
 }
 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();
 }
Exemplo n.º 5
0
 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('*****@*****.**', 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();
 }