Jump to content

devilinc

Members
  • Posts

    96
  • Joined

  • Last visited

    Never

Posts posted by devilinc

  1. the add function with error message comes correctly below the textfield input with the check limit function if it is static value for the checkLimit function

    'customer_monthlyamount' => array(
    								'rule' => array('checkLimit', 1500),
    								'message' => 'You have exceeded your alotted limit'
    							)

     

    but if it is

    'customer_monthlyamount' => array(
    								'rule' => array('checkLimit', $_SESSION['limit']),
    								'message' => 'You have exceeded your alotted limit'
    							)

     

     

  2. i dont know what i am missing but it doesnt work for me....this is what i put in my model

    
    var $validate   = array( 'customer_name' => array('valid' => array('rule' => 'notEmpty','message' => 'This field cannot be left blank'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This Customer Name has already been used')),
    
    						'customer_monthlyamount' => array('rule' => array('checkLimit', $_SESSION['limit']),'message' => 'you have exceeded your limit'),
    						'customer_loginname'=>array('valid' => array('rule' => 'notEmpty','message' => 'This field cannot be left blank'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This Login Name has already been selected by a user. Please choose a different login name.'),'customer_loginnameRule-1' => array('rule' => 'alphaNumeric','message' => 'Only alphabets and numbers allowed','last' => true),
            
    													),  
    
    						'customer_email' => array('valid' => array('rule' => 'email','message' => 'Please enter a valid email address'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This email address has already been used')),
    						'customer_confpassword' => array('rule' => array('minLength','6'),'required' => true,'allowEmpty' => false,'message' => 'Password must have at least 6 characters'),'customer_loginpassword' => array('rule' => array('minLength','6'),'required' => true,'allowEmpty' => false,'message' => 'Password must have at least 6 characters'),'customer_loginpassword' => array('identicalFieldValues' => array('rule' => array('identicalFieldValues', 'customer_confpassword' ),'message' => 'Confirm password must be same as Password')),
    					  );
    
    
    
    function checkLimit($check,$limit){
    		return $check['customer_monthlyamount'] < $limit;	
    	}
    
    

     

     

     

     

    but it doesnt seem to work........$_SESSION['limit'] is the value from my function but it doesnt seem to work......

     

     

     

    tried beforeSave() too.....here it works for add with my error message displayed but for edit the logic works but no error message displayed...

    var $validate   = array( 'customer_name' => array('valid' => array('rule' => 'notEmpty','message' => 'This field cannot be left blank'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This Customer Name has already been used')),
    						'customer_monthlyamount' => array('rule' => 'notEmpty'),
    						'customer_loginname'=>array('valid' => array('rule' => 'notEmpty','message' => 'This field cannot be left blank'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This Login Name has already been selected by a user. Please choose a different login name.'),'customer_loginnameRule-1' => array('rule' => 'alphaNumeric','message' => 'Only alphabets and numbers allowed','last' => true),
            
    													),  
    
    						'customer_email' => array('valid' => array('rule' => 'email','message' => 'Please enter a valid email address'),
    											  'unique' => array('rule' => 'isUnique','message' => 'This email address has already been used')),
    						'customer_confpassword' => array('rule' => array('minLength','6'),'required' => true,'allowEmpty' => false,'message' => 'Password must have at least 6 characters'),'customer_loginpassword' => array('rule' => array('minLength','6'),'required' => true,'allowEmpty' => false,'message' => 'Password must have at least 6 characters'),'customer_loginpassword' => array('identicalFieldValues' => array('rule' => array('identicalFieldValues', 'customer_confpassword' ),'message' => 'Confirm password must be same as Password')),
    					  );
    function beforeSave(){
    		//if(!isset($id)){
    			if($this->data['Customer']['customer_monthlyamount'] <= $_SESSION['limit']){
    				$this->data['Customer']['customer_monthlyamount'] = $this->data['Customer']['customer_monthlyamount'];				
    				//echo "<font color ='red'>the monthly limit alloted for your deparment is over.sorry you cannot register</font>";
    				return true;
    			}else{
    					echo "<font color ='red'>the monthly limit alloted for your deparment is over.sorry you cannot register</font>";
    					return false;
    				}
    		//}
    	}
    

     

    can you please direct me on the right path?

     

  3. ok now i get the beforeSave() working correctly with my form values still there but my url is changed now....i pass an id also with the url but now the id is not present and hence my function never runs and i get the form with the values entered back to me.........it doesnt save...what am i doing wrong?

  4. i want to check a condition when the user enters a text field input in the form....i want to check that the value doesnt exceed a value already listed...i run this condition before if($this->save($this->data))....what happens on submission is that the condition succeeds BUT the form entries entered by customer gets wiped out completely and he has to enter from scratch....i want on form submit to display an error message and the text fields should retain all the values and better still if the error message comes below the text field with conditional statement.....what do i do??? please help.....saw a beforeSave() ran it but I think I am running it the wrong way....i just enter the conditon test inside beforeSave() written in my model.....but i dont make a call to it in the controller....so could anyone guide me?

  5. i have 3-4 checkbox in my page which when clicked should display data by ajax request in cakephp....currently i do it in a sneaky way where i manipulate the jquery tutorial for link by replacing with checkbox but i face many issues here....i cant know if the checkbox is set or unset....on top of that it takes in the id of a single checkbox at a time irrespective of how many checkbox is set or unset....

    there is an ajax->observeField but i dont know how to implement it....any help to get me going?

  6. i have made a shopping summary page with values written in session and printed them in my view file....i now want an option for the user to update quantity only....if he does it i need to call an ajax function to update my session values but how to go about it?i am clueless in cake.....

  7. when my page is refreshed and i click the first time on modal box i get a blank box on screen....if i click again i get my view file....what could be wrong? I checked the error console and this is what i got....hope it might be helpful.....

    uncaught exception: ModalBox loading Error: TypeError : Effect.Morph is not a constructor

  8. i know we can use for no table but in the end this is how i thought of it....to leave catalog as a link to categories so when clicked on catalog it gives the list of categories and then products under categories....so two controllers each for their specific tasks namely categories_controller.php and products_controller.php.....

  9. Here is my scenario. I have a tab namely catalogs which has categories and products under it.

     

    Catalog is lets say the menu of categories and when we click on category we get to see the products under it.

    So, Now, do i have to make separate controllers for catalog, categories and products? because i use models for categories and products but not for catalogs

  10. this is how far i have reached...could anyone advise me if i have written something wrong?

    $conditions = array( "OR" => array (
    													"department_name LIKE" => "%".$this->data['Department']['department_search']."%",
    													"department_email LIKE" => "%".$this->data['Department']['department_search']."%"
        													)
    									);
    				$search_results = $this->Department->find('all', array('conditions' => $conditions));

  11. here is my code for better understanding only the save or not save part

    if ($this->Customer->save($this->data)) 
    		   {
    				// $this->redirect(array('controller' => 'realteams', 'action' => 'index'));			
    
    				//$data = $this->paginate('Customer');
    				 $this->redirect(array('action' => '/customerslist/'.$_SESSION['department_id']));
    				  unset($_SESSION['department_id']);
    				  ob_flush();
    		   }
    		   else 
    		   {
    			  $this->Session->setFlash(__('The Customer could not be saved. Please, try again.', true));
    			  //$this->redirect(array('action' => '/customerscreate/'.$_SESSION['department_id']));
    			   }

     

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.