本文整理汇总了PHP中ContactForm::removeElement方法的典型用法代码示例。如果您正苦于以下问题:PHP ContactForm::removeElement方法的具体用法?PHP ContactForm::removeElement怎么用?PHP ContactForm::removeElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ContactForm
的用法示例。
在下文中一共展示了ContactForm::removeElement方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: editAction
/** Edit staff profile
*/
public function editAction()
{
$form = new ContactForm();
$form->submit->setLabel('Save');
$form->removeElement('role');
$form->removeElement('alumni');
$form->removeElement('identifier');
$form->removeElement('role');
$form->removeElement('dbaseID');
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$address = $form->getValue('address_1') . ',' . $form->getValue('address_2') . ',' . $form->getValue('town') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ', UK';
$coords = $this->_geocoder->getCoordinates($address);
if ($coords) {
$lat = $coords['lat'];
$long = $coords['lon'];
} else {
$lat = NULL;
$lon = NULL;
}
$woeid = $place->woeid;
$updateData = array('firstname' => $form->getValue('firstname'), 'lastname' => $form->getValue('lastname'), 'email_one' => $form->getValue('email_one'), 'email_two' => $form->getValue('email_two'), 'address_1' => $form->getValue('address_1'), 'address_2' => $form->getValue('address_2'), 'town' => $form->getValue('town'), 'county' => $form->getValue('county'), 'postcode' => $form->getValue('postcode'), 'telephone' => $form->getValue('telephone'), 'fax' => $form->getValue('fax'), 'region' => $form->getValue('region'), 'website' => $form->getValue('website'), 'profile' => $form->getValue('profile'), 'updated' => $this->getTimeForForms(), 'updatedBy' => $this->getIdentityForForms(), 'latitude' => $lat, 'longitude' => $lon, 'woeid' => $woeid);
foreach ($updateData as $key => $value) {
if (is_null($value)) {
unset($updateData[$key]);
}
}
$contacts = new Contacts();
$where = array();
$where[] = $contacts->getAdapter()->quoteInto('dbaseID = ?', $this->getIdentityForForms());
$insert = $contacts->update($updateData, $where);
$this->_flashMessenger->addMessage('Contact information for ' . $form->getValue('firstname') . ' ' . $form->getValue('lastname') . ' updated!');
$this->_redirect('/users/account/');
} else {
$form->populate($formData);
}
} else {
$id = (int) $this->getIdentityForForms();
if ($id != 0) {
$contacts = new Contacts();
$contact = $contacts->fetchRow('dbaseID = ' . $id);
if (is_null($contact)) {
throw new Exception('Admin has not yet set up a profile for you');
} else {
$form->populate($contact->toArray());
}
}
}
}
示例2: editAction
/** Edit staff profile
* @access public
* @return void
* @throws Pas_Exception_Param
*/
public function editAction()
{
$form = new ContactForm();
$form->submit->setLabel('Save');
$form->removeElement('role');
$form->removeElement('alumni');
$form->removeElement('identifier');
$form->removeElement('role');
$form->removeElement('dbaseID');
$this->view->form = $form;
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$address = $form->getValue('address_1') . ',' . $form->getValue('address_2') . ',' . $form->getValue('town') . ',' . $form->getValue('county') . ',' . $form->getValue('postcode') . ', UK';
$coords = $this->_geocoder->getCoordinates($address);
if ($coords) {
$lat = $coords['lat'];
$lon = $coords['lon'];
$pm = new Pas_Service_Geo_GeoPlanet($this->_helper->config()->webservice->ydnkeys->appid);
$place = $pm->reverseGeoCode($lat, $lon);
$woeid = $place['woeid'];
} else {
$lat = null;
$lon = null;
$woeid = null;
}
$updateData = $form->getValues();
$updateData['latitude'] = $lat;
$updateData['longitude'] = $lon;
$updateData['woeid'] = $woeid;
$where = array();
$where[] = $this->_contacts->getAdapter()->quoteInto('dbaseID = ?', $this->getIdentityForForms());
$this->_contacts->update($updateData, $where);
$this->getFlash()->addMessage('Contact information updated!');
$this->redirect('/users/account/');
} else {
$form->populate($formData);
}
} else {
$contact = $this->_contacts->fetchRow($this->_contacts->select()->where('dbaseID = ' . $this->getIdentityForForms()));
if (is_null($contact)) {
throw new Pas_Exception_Param('Admin has not yet set up a profile for you', 500);
} else {
$form->populate($contact->toArray());
}
}
}