Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #11 (permalink)  
Old 07-09-2008, 06:36 PM
Senior Member
 
Join Date: Jun 2008
Location: Florida
Posts: 108
Default

What does a

Code:
print_r($_POST);
look like when submitting the form in the edit mode? Do you see the value pair for the hidden field as expected?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #12 (permalink)  
Old 07-09-2008, 06:52 PM
Junior Member
 
Join Date: Jun 2008
Location: earth
Posts: 14
Default

POST shows nothing when in 'edit'

but when you submit and back at 'controller/phone' (the rest of the values in the url are left off since it's just showing itself now.)

POST:

Array
(
[pnum] => 9735551212
[cc] =>
[numtype] => C
[Submit] => Submit
[id] => 1
)


SANITIZED (when placed just inside the (isPost) check and before (isValid):
Array
(
[pnum] =>
[cc] =>
[numtype] =>
)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #13 (permalink)  
Old 07-09-2008, 06:54 PM
Senior Member
 
Join Date: Jun 2008
Location: Florida
Posts: 108
Default

What are you passing to isValid(), and what does your form code creation look like?

Is there anything in the getMessages() method of your form object?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #14 (permalink)  
Old 07-09-2008, 07:19 PM
Junior Member
 
Join Date: Jun 2008
Location: earth
Posts: 14
Default

To get here, links look like:

/user/phone/number/edit/id/2
or
/user/phone/number/new



Here is the entire action and form:

Code:
    public function getPhoneForm() {
    	if (null === $this->_form) {
    		$this->_form = new User_PhoneNumbersForm(array(
            'action' => '/personnel/phone',
            'method' => 'post',
        	));
    	}
    	return $this->_form;
    }



    public function phoneAction() {
		$this->_helper->layout->disableLayout();

    	// get the form and save to a view var
		$this->view->form = $this->getform();

		$params = $this->_request->getParams();

        // check if the form was submitted via post
        if ($this->_request->isPost()) {
			print_r($_POST);
            $sanitizedValues = $this->view->form->getValues();
			if (isset($sanitizedValues['id'])) {
				$this->view->form->addPhoneRecID($sanitizedValues['id']);
			}

            if ($this->view->form->isValid($this->_request->getPost())) {
                // the form is valid, save to db via a method within this controller
            } else {
                // the form is not valid, send the user back to the form with a message generated by Zend_Form
            }
        } else {
			switch ($params['number'])
			{
				case 'new':
					break;

				case 'edit':
						$this->view->form->addPhoneRecID($params['id']);
						$this->view->form->populate($this->getNumberInfo($params['id']));
					break;

				default:
			}
        }

    }
    
    
class User_PhoneNumbersForm extends Our_Form {


	public $numbers = array();

	public $number_field_options = array(
		        'W' => 'Work',
		        'H' => 'Home',
		        'C' => 'Cell'
		);




    public function __construct($options = null) {
        parent::__construct($options);

        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')),
            array('Description', array('placement' => 'prepend')),
            'Form'
        ));

    }


	public function init()
	{

        $this->addElement('text', 'pnum', array(
            'filters' => array('StringTrim', 'StringToLower'),
            'validators' => array(
                array('regex',true, array('/^[0-9.()]{7,20}$/i')),
                array('StringLength', true, array(7, 20)),
            ),
            'required' => true,
            'label' => 'Phone Number:',
			'class' => 'text'
        ));

        $this->addElement('text', 'cc', array(
            'filters' => array('StringTrim', 'StringToLower'),
            'validators' => array(
            	'Digits',
                array('StringLength', true, array(1, 4)),
            ),
            'required' => true,
            'label' => 'Country Code:',
			'class' => 'text'
        ));

        $this->addElement('select', 'numtype', array(
             'label' => 'Type',
             'isArray' => false,
             'multiOptions' => $this->number_field_options
         ) );


        $this->addDisplayGroup(
            array('pnum', 'cc', 'numtype'),
            	'phonenumbers',
            array(
                'disableLoadDefaultDecorators' => true,
                'decorators' => $this->_standardGroupDecorator,
                'legend' => 'Add New Number:',
            )
        );


        $updateinfo = $this->addElement('submit', 'Submit', array(
            'required' => false,
            'ignore' => true,
            'label' => 'Submit',
			'class' => 'button'
        ));

	}


	public function addPhoneRecID($val) {
	  	$this->addElement('hidden', 'id', array(
        'filters' => array('StringTrim'),
        'validators' => array(
            'Digits',
            array('Between',true, array(1,20))
        ),
        	'value' => $val,
            'required' => true
        ));
	}


}
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:44 PM.