/** * Overridden isValid() method for pre-validation code. * * @param array $formData data typically from a POST or GET request. * * @return bool */ public function isValid($formData = array()) { // "General" e-mail address is compulsory $this->getElement("emailGENERAL")->setRequired(true); // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); // If correspondence address is set to be the same as insured address, copy the address values across if (isset($formData['cor_same_address']) && $formData['cor_same_address'] == 'yes') { // NOTE: THIS BIT OF CODE MEANS BOTH ADDRESS SUBFORMS MUST APPEAR ON THE SAME PAGE $formData['cor_house_number_name'] = $formData['ins_house_number_name']; $formData['cor_postcode'] = $formData['ins_postcode']; $formData['cor_address'] = $formData['ins_address']; $findPostcode = $formData['ins_postcode']; } // If a postcode is present, look it up and populate the allowed values of the associated dropdown if (isset($formData['cor_postcode']) && trim($formData['cor_postcode']) != '') { $postcode = trim($formData['cor_postcode']); $postcodeLookup = new Manager_Core_Postcode(); $addresses = $postcodeLookup->getPropertiesByPostcode(preg_replace('/[^\\w\\ ]/', '', $postcode)); $addressList = array('' => '--- please select ---'); foreach ($addresses as $address) { $addressList[$address['id']] = $address['singleLineWithoutPostcode']; } $cor_address = $this->getElement('cor_address'); $cor_address->setMultiOptions($addressList); $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList))); $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Correspondence address does not match with postcode')); $cor_address->addValidator($validator, true); } // If a value for an address lookup is present, the house name or number is not required if (isset($formData['cor_postcode'])) { $this->getElement('cor_house_number_name')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { if (isset($formData['need_contents_insurance']) && $formData['need_contents_insurance'] == 'yes') { // User wants contents insurance - so we need to know if the property is furnished $this->getElement('property_furnished')->setRequired(true); if (isset($formData['property_furnished']) && $formData['property_furnished'] == 'yes') { // User has said they want contents insurance and the property // is furnished - so we need to make the extra information mandatory $this->getElement('contents_amount')->setRequired(true); $this->getElement('contents_excess')->setRequired(true); $this->getElement('contents_accidental_damage')->setRequired(true); } else { // Property is unfurnished so we don't need to know any of the extra data $this->getElement('contents_amount')->setRequired(false); $this->getElement('contents_excess')->setRequired(false); $this->getElement('contents_accidental_damage')->setRequired(false); unset($formData['contents_amount']); unset($formData['contents_excess']); unset($formData['contents_accidental_damage']); } } else { // Make the extra data optional as they haven't said they want contents insurance $this->getElement('property_furnished')->setRequired(false); $this->getElement('contents_amount')->setRequired(false); $this->getElement('contents_excess')->setRequired(false); $this->getElement('contents_accidental_damage')->setRequired(false); unset($formData['contents_amount']); unset($formData['contents_excess']); unset($formData['contents_accidental_damage']); } // Call original isValid() return parent::isValid($formData); }
public function isValid($formData = array()) { if (isset($formData['ins_property_postcode']) && trim($formData['ins_property_postcode']) != '') { $postcode = trim($formData['ins_property_postcode']); $postcodeLookup = new Manager_Core_Postcode(); $addresses = $postcodeLookup->getPropertiesByPostcode(preg_replace('/[^\\w\\ ]/', '', $postcode)); $addressList = array('' => '--- please select ---'); if (isset($postcode) && preg_match('/^IM|^GY|^JE/i', $postcode)) { return; } else { foreach ($addresses as $address) { $addressList[$address['id']] = $address['singleLineWithoutPostcode']; } } $ins_address = $this->getElement('property_address'); $ins_address->setMultiOptions($addressList); $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList))); $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Insured address does not match with postcode')); $ins_address->addValidator($validator, true); } // If a value for an address lookup is present, the house name or number is not required if (isset($formData['ins_property_postcode'])) { $this->getElement('property_number_name')->setRequired(false); } return parent::isValid($formData); }
public function isValid($postData) { $pageSession = new Zend_Session_Namespace('portfolio_insurance_quote'); $customerReferenceNumber = $pageSession->CustomerRefNo; $propertyManager = new Manager_Insurance_Portfolio_Property(); $propertyObjects = $propertyManager->fetchAllProperties($customerReferenceNumber); $propertyArray = $propertyObjects->toArray(); $optionList = array('' => '--- please select ---'); foreach ($propertyArray as $property) { $optionList[$property['id']] = $property['address1'] . " " . $property['address2'] . " " . $property['address3'] . " " . $property['postcode']; } // Get the subfoem element for property address that the bank may have interest in $propertyAddressSelect = $this->getElement('claim_property'); $propertyAddressSelect->setMultiOptions($optionList); $validator = new Zend_Validate_InArray(array('haystack' => array_keys($optionList))); $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Not in list')); $propertyAddressSelect->addValidator($validator, true); // Set the selected to 0 $propertyAddressSelect->setValue('0'); $claimTypeList = array('' => '--- please select ---'); $claimTypesSelect = $this->getElement('claim_type'); $claimTypes = new Datasource_Insurance_PreviousClaimTypes(); $claimTypeObjects = $claimTypes->getPreviousClaimTypes(Model_Insurance_ProductNames::LANDLORDSPLUS); foreach ($claimTypeObjects as $ClaimType) { $claimTypeList[$ClaimType->getClaimTypeID()] = $ClaimType->getClaimTypeText(); } $claimTypesSelect->setMultiOptions($claimTypeList); return parent::isValid($postData); }
public function isValid($formData = array()) { // Call original isValid() first before doing further validation checks // $isValid=parent::isValid($formData); $auth = Zend_Auth::getInstance(); $auth->setStorage(new Zend_Auth_Storage_Session('hl_connect')); // Get ASN from auth object $agentSchemeNumber = $auth->getStorage()->read()->agentschemeno; if ($formData['question1'] === 'yes') { $this->getElement('claiminfo')->setRequired(true); } else { $this->getElement('claiminfo')->setRequired(false); } if (isset($formData['email_address']) && trim($formData['email_address']) != '') { // The agent manager can throw execptions, for web use we need to treat them as invalid and return false $agentManager = new Manager_Core_Agent(); $agentObj = $agentManager->getAgent($agentSchemeNumber); // Get referencing email address (Cat 2) $ref_email_address = $agentManager->getEmailAddressByCategory(2); // Referencing email address is not allowed if ($formData['email_address'] === $ref_email_address) { $this->getElement('email_address')->addError('Please provide Landlord email address.'); $isValid = false; } // Confirmed email address filed value should be same as email address field value if (isset($formData['confirm_email_address']) && trim($formData['confirm_email_address']) != '') { if ($formData['email_address'] !== $formData['confirm_email_address']) { $this->getElement('confirm_email_address')->addError('Invalid confirmed email address.'); $isValid = false; } } } // return $isValid; return parent::isValid($formData); }
public function isValid($formData = array()) { $isValid = parent::isValid($formData); if ($formData['property_managed'] === 'Let Only') { $this->getElement('LL_Permission')->setRequired(true); } else { $this->getElement('LL_Permission')->setRequired(false); } /* $tenancyDate = new Zend_Date ($formData['tenancy_startdate']); $policyDate = new Zend_Date ($formData['policy_startdate']); $daysDiff = $policyDate->sub($tenancyDate)->toValue()/60/60/24; // Policy start date should be between 0 to max 14 days after the tenancy start date if ($daysDiff < 0 || $daysDiff > 14) { $this->getElement('tenancy_startdate')->addError('Policy start date should be maximum 14 days after the tenancy start date'); $isValid=false; } */ // Monthly rental amount cannot be greater than £2500 for reference type 'Other Credit Check' and 'Insight' if (($formData['type'] === 'Other Credit Check' || $formData['type'] === 'Insight') && $formData['property_rental'] > 2500) { $this->getElement('property_rental')->addError('Monthly rental amount cannot be greater than £2500 for the selected reference type'); $isValid = false; } return $isValid; //return parent::isValid($formData); }
public function isValid($formData = array()) { // If a postcode is present, look it up and populate the allowed values of the associated dropdown if (isset($formData['postcode']) && trim($formData['postcode']) != '') { $postcode = trim($formData['postcode']); $postcodeLookup = new Manager_Core_Postcode(); $addresses = $postcodeLookup->getPropertiesByPostcode(preg_replace('/[^\\w\\ ]/', '', $postcode)); $addressList = array('' => '--- please select ---'); foreach ($addresses as $address) { $addressList[$address['id']] = $address['singleLineWithoutPostcode']; } $address = $this->getElement('address'); $address->setMultiOptions($addressList); $validator = new Zend_Validate_InArray(array('haystack' => array_keys($addressList))); $validator->setMessages(array(Zend_Validate_InArray::NOT_IN_ARRAY => 'Address does not match with postcode')); $address->addValidator($validator, true); } // If a value for an address lookup is present, the house name or number is not required if (isset($formData['address_postcode']) && $formData['address_postcode'] != '') { $this->getElement('postcode')->setRequired(false); $this->getElement('address')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // Get rental payment data $pageSession = new Zend_Session_Namespace('online_claims'); $manager = new Manager_Insurance_RentGuaranteeClaim_RentalPayment(); $paymentData = $manager->getRentalPayments($pageSession->ClaimReferenceNumber); // If there is not any stored due data, all fields are mandatory so we get at least one entry $noPaymentsDueEntered = true; if (count($paymentData['data']) > 0) { // Run through data present looking for payments due entered foreach ($paymentData['data'] as $payment) { if ($payment['date_due'] != 'N/A') { $noPaymentsDueEntered = false; break 1; } } } if ($noPaymentsDueEntered) { $this->getElement('date_due')->setRequired(true); $this->getElement('amount_due')->setRequired(true); } // If there is any partly entered data, all fields are mandatory if (isset($formData['date_due']) && $formData['date_due'] != '' || isset($formData['amount_due']) && $formData['amount_due'] != '') { $this->getElement('date_due')->setRequired(true); $this->getElement('amount_due')->setRequired(true); } return parent::isValid($formData); }
public function isValid($formData) { if (parent::isValid($formData)) { return $this->checkReliantFields($formData); } else { return false; } }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); $session = new Zend_Session_Namespace('homelet_global'); $agentSchemeNumber = $session->agentSchemeNumber; // Call original isValid() return parent::isValid($formData); }
public function isValid($postData) { // If is_associated is 1 then the 'associated_text' text field become required if ($postData['is_associated'] == 1) { $this->getElement('associated_text')->setRequired(true); } return parent::isValid($postData); }
public function isWhenFormValid($formData, $validateStartDate, $originalStartDate, $update, $instanceId) { if (parent::isValid($formData)) { return self::checkReliantFields($formData, $validateStartDate, $originalStartDate, $update, $instanceId); } else { return false; } }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // If there is any partly entered data, all fields are mandatory if (isset($formData['date_received']) && $formData['date_received'] != '' || isset($formData['amount_received']) && $formData['amount_received'] != '') { $this->getElement('date_received')->setRequired(true); $this->getElement('amount_received')->setRequired(true); } return parent::isValid($formData); }
public function isValid($formData) { if (isset($formData['need_prestige_rent_guarantee']) && $formData['need_prestige_rent_guarantee'] == 'yes') { $this->getElement('rent_amount')->setRequired(true); } else { $this->getElement('rent_amount')->setRequired(false); } return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code. * * @param array $formData data typically from a POST or GET request. * * @return bool */ public function isValid($formData = array()) { if ($formData['type'] === 'Other Credit Check' || $formData['type'] === 'Other Full Reference') { $this->getElement('provider')->setRequired(true); } else { $this->getElement('provider')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $session = new Zend_Session_Namespace('homelet_global'); $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); // Check if contents_cover_a is "15000+", if so make contents_cover_b validation mandatory if (isset($formData['contents_cover_a']) && $formData['contents_cover_a'] == '15000+') { $this->getElement('contents_cover_b')->setRequired(true); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // Don't show both error messages, one is enough if ($formData['declaration_statement'] != 1 && $formData['declaration_notadvised'] != 1) { // Modify the mandatory-ness to give just one error $this->getElement('declaration_statement')->setRequired(true); $this->getElement('declaration_notadvised')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // Filter for currency elements $currencyFilterElements = array('claim_value'); foreach ($currencyFilterElements as $filterElement) { if (isset($formData[$filterElement])) { $formData[$filterElement] = preg_replace(array('/[^\\d\\.]/'), array(''), $formData[$filterElement]); } } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); // Populate $formData with data from model, if available if (isset($pageSession->CustomerRefNo)) { $marketQuestionDS = new Datasource_Core_ManagementInformation_MarketingAnswers(); $customerData['how_hear'] = $marketQuestionDS->getAnswer($pageSession->PolicyNumber); // Pipe into $formData, with any existing $formData content taking precedence $formData = array_merge($customerData, $formData); } // Call original isValid() return parent::isValid($formData); }
public function isValid($formData = array()) { //Zend_Debug::dump($formData); if (isset($formData['ico_select']) && $formData['ico_select'] != 'yes') { // un require some fields $this->getElement('ico_renewal_date')->setRequired(false); } else { // Turn em back on $this->getElement('ico_renewal_date')->setRequired(true); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); if (isset($formData['bicycle']) && $formData['bicycle'] == 'yes') { if (trim($formData['bicycle_make']) != '' || trim($formData['bicycle_model']) != '' || trim($formData['bicycle_serial']) != '' || trim($formData['bicycle_value']) != '') { $this->getElement('bicycle_make')->setRequired(true); $this->getElement('bicycle_model')->setRequired(true); $this->getElement('bicycle_value')->setRequired(true); } } // Call original isValid() return parent::isValid($formData); }
public function isValid($postData) { // If prestige rent guarantee is added to the quote this form isn't even shown because it's included for free // so we need to make the choice not required for validation purposes $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); if (isset($pageSession->quoteID)) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID); if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::RENT_GUARANTEE) || isset($postData['need_prestige_rent_guarantee']) && $postData['need_prestige_rent_guarantee'] == 'yes') { $this->getElement('need_legal_expenses')->setRequired(false); } } return parent::isValid($postData); }
public function isValid($data) { if (isset($data['answer'])) { $this->populate($data['answer']); if (sizeof($data['answer']) < 2) { $this->addError('Minimal 2 Jawaban'); } } else { $this->addError('Jawaban Tidak Boleh Kosong'); $this->clearElements(); } return parent::isValid($data); }
public function isValid($postData) { // If Emergency Assistance is included for free // so we need to make the choice not required for validation purposes $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); if (isset($pageSession->quoteID)) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID); if (!$quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) && !$quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) { $this->getElement('need_boiler_heating')->setRequired(false); } } return parent::isValid($postData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // Check if user is making a CC purchase, if so ignore DD fields for validation by making them non-mandatory if (isset($formData['payment_method']) && 'cc' == $formData['payment_method']) { $this->getElement('dd_inyourname')->setRequired(false); $this->getElement('dd_onlyauthorised')->setRequired(false); $this->getElement('dd_accountname')->setRequired(false); $this->getElement('bank_account_number')->setRequired(false); $this->getElement('bank_sortcode_number')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { // If a landline phone number is given, mobile is not mandatory if (isset($formData['phone_number']) && trim($formData['phone_number']) != '') { $this->getElement('mobile_number')->setRequired(false); } // If a mobile phone number is given, landline is not mandatory if (isset($formData['mobile_number']) && trim($formData['mobile_number']) != '') { $this->getElement('phone_number')->setRequired(false); } // Call original isValid() return parent::isValid($formData); }
public function isValid($postData) { // If building cover is added to the quote this form isn't even shown because Emergency Assistance is included for free // so we need to make the choice not required for validation purposes $pageSession = new Zend_Session_Namespace('landlords_insurance_quote'); if (isset($pageSession->quoteID)) { $quoteManager = new Manager_Insurance_LandlordsPlus_Quote($pageSession->quoteID); if ($quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::BUILDING_COVER) || $quoteManager->hasProduct(Manager_Insurance_LandlordsPlus_Quote::CONTENTS_COVER)) { $this->getElement('need_emergency_assistance')->setRequired(false); } } return parent::isValid($postData); }
/** * Overridden isValid() method for pre-validation code. * * @param array $formData data typically from a POST or GET request. * * @return bool */ public function isValid($formData = array()) { // Insight can only be selected for product type "absolute", "promise" or "essential" if (isset($formData['type']) && trim($formData['type']) == 'insight') { if (isset($formData['product']) && (trim($formData['product']) == 'absolute' || trim($formData['product']) == 'promise' || trim($formData['product']) == 'essential')) { // All OK, do nothing } else { // Force an error $this->addError('Reference type invalid'); } } // Call original isValid() return parent::isValid($formData); }
/** * Overridden isValid() method for pre-validation code * * @param array $formData data typically from a POST or GET request * * @return bool */ public function isValid($formData = array()) { $session = new Zend_Session_Namespace('homelet_global'); $pageSession = new Zend_Session_Namespace('tenants_insurance_quote'); // Check if someone said "Yes" to wanting cover for possessions, but hasn't added any, and if so make fields mandatory if (isset($formData['above_x']) && $formData['above_x'] == 'yes') { if (trim($formData['possession_categoryId']) != '' || trim($formData['possession_value']) != '') { $this->getElement('possession_categoryId')->setRequired(true); $this->getElement('possession_description')->setRequired(true); $this->getElement('possession_value')->setRequired(true); } } // Call original isValid() return parent::isValid($formData); }