Skip to main contentdfsdf

    • Alnum

          

        Returns TRUE if and only if $value contains only  alphabetic and digit characters. This validator includes an option to also consider  white space characters as valid.

      • $valid = new Zend_Validate_CreditCard(array(
      •  
      •     'type' => array(Zend_Validate_CreditCard::AMERICAN_EXPRESS)
      •  
      • ));

    2 more annotations...

  • form 2

    May 31, 10

    required and notempty must be coded both

    • When an element is required, a 'NotEmpty' validator is added to the  top of the validator chain, ensuring that the element has a value  when required.
    • $password->addValidator('StringLength', false, array(6))
  • May 13, 10

    class DocumentForm extends Zend_Form
    {
    function addAction()
    {
    $form = new DocumentForm();
    $this->view->form = $form;

    if ($this->_request->isPost()) {

    $formData = $this->_request->getPost();
    if ($form->isValid($formData)) {

    /* Uploading Document File on Server */
    $upload = new Zend_File_Transfer_Adapter_Http();
    $upload->setDestination("/uploads/files/");
    try {
    // upload received file(s)
    $upload->receive();
    } catch (Zend_File_Transfer_Exception $e) {
    $e->getMessage();
    }

    // so, Finally lets See the Data that we received on Form Submit
    $uploadedData = $form->getValues();
    Zend_Debug::dump($uploadedData, 'Form Data:');

    // you MUST use following functions for knowing about uploaded file
    # Returns the file name for 'doc_path' named file element
    $name = $upload->getFileName('doc_path');

    # Returns the size for 'doc_path' named file element
    # Switches of the SI notation to return plain numbers
    $upload->setOption(array('useByteString' => false));
    $size = $upload->getFileSize('doc_path');

    # Returns the mimetype for the 'doc_path' form element
    $mimeType = $upload->getMimeType('doc_path');

    // following lines are just for being sure that we got data
    print "Name of uploaded file: $name
    ";
    print "File Size: $size
    ";
    print "File's Mime Type: $mimeType";

    // New Code For Zend Framework :: Rename Uploaded File
    $renameFile = 'newName.jpg';

    $fullFilePath = '/images/'.$renameFile;

    // Rename uploaded file using Zend Framework
    $filterFileRename = new Zend_Filter_File_Rename(array('target' => $fullFilePath, 'overwrite' => true));

    $filterFileRename -> filter($name);

    exit;
    }

    } else {

    // this line will be called if data was not submited
    $form->populate($formData);
    }
    }
    }

    • lass DocumentForm extends Zend_Form
  • May 13, 10

    Release Better Code Sooner, Increase Developer Productivity

    • Zend_Form_Element_Captcha
    • Zend_Form_Element_File

    5 more annotations...

    • $validator = new Zend_Validate_StringLength(6, 20);
    • Note: Providing Custom Validator Error Messages

    3 more annotations...

      • Example #4 Setting Filters for All Elements

            

          In some cases, you may want to apply the same filter to all  elements; a common case is to trim() all values: 

          
        1. $form->setElementFilters(array('StringTrim'));
    • Display Groups

    8 more annotations...

1 - 7 of 7
20 items/page
List Comments (0)