You are not logged in.
In this video, we're going to work on building a custom validator for our composite form element for phone numbers. The nice thing about this validator is that it can then be applied to any sort of textbox. Next week, we'll ajaxify our final form with a handful of lines of jQuery.
Grab a copy of the project or browse the repository.
Offline
Jon,
I was curious how you would do this with Zend_Form_Dojo fields. Does it work the same?
Offline
Hey Kobe,
I'm afraid I don't have experience with Zend_Form_Dojo, however I imagine that it would also work with Dojo forms...
Offline
hello jon
i created a custom element(phone) as you taught, i could save value of this element to database, but i could not read and show in this custom element for edit..
i used same this in model
public function findCustomerPhone($id){
phone = $this->find ( $id )->current ();
return $phone->toArray();
}
and same following code in my controller
function edit(){
.
.
.
$id = $this->_request->getParam ( 'id' );
$customer = $customerModel->findCustomerPhone($id);
$frmcustomer->populate ( $customer );
}
i can see other fields in my form but i can not see phone value
how can i populate this element value from database to form ?
thanks
Last edited by ulduz114 (2010-04-05 11:09:32)
Offline
Hey Ulduz,
The populate method is probably going to run the setValue() method on the form element. This is assumed to be a string, however you're returning an array from findCustomerPhone()
Offline
Hello Jon,
I found this screencast to be very helpful. But how do I generate more than one phone element in the same form? The following create six fields for the second phone element:
$cellPhone = new ZC_Form_Element_Phone(‘phone’);
$cellPhone->addValidator(new ZC_Validate_CellPhone());
$cellPhone->setLabel(‘Cell Number:’)->setRequired(true);
$directPhone = new ZC_Form_Element_Phone(‘directphone’);
$directPhone->addValidator(new ZC_Validate_CellPhone());
$directPhone->setLabel(‘Direct Number:’)->setRequired(true);
Offline
Hi ryy705, you could use a foreach, create an array and then loop through those lines with the given keys... (e.g. array('Direct Number' => 'directphone', etc...) )
Offline