本文整理汇总了PHP中Zend_Form::isValid方法的典型用法代码示例。如果您正苦于以下问题:PHP Zend_Form::isValid方法的具体用法?PHP Zend_Form::isValid怎么用?PHP Zend_Form::isValid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend_Form
的用法示例。
在下文中一共展示了Zend_Form::isValid方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: saveAction
public function saveAction()
{
$this->getRequest()->isPost();
$this->buildForm("admin/group/save");
if ($this->gForm->isValid($_POST)) {
$values = $this->gForm->getValues();
}
//Build Group Object
$group = new Group();
//Upload Logo
if (copy($values['logo'], Zend_Registry::get('config')->files->logo->dir . DIRECTORY_SEPARATOR . basename($values['logo']))) {
$values['logo'] = Zend_Registry::get('config')->files->logo->dir . "/" . basename($values['logo']);
}
//Convert polygon cordenates
preg_match_all("/\\(([0-9\\.\\,\\-\\s]*)\\)[\\,]?/", $values['area_coords'], $rawcoords);
foreach ($rawcoords[1] as $coord) {
$cvalues = explode(",", $coord);
$cobj = new stdClass();
$cobj->lat = trim($cvalues[0]);
$cobj->lng = trim($cvalues[1]);
$coords[] = $cobj;
}
$values['area_coords'] = json_encode($coords);
//Register Administrators
$admins = explode(",", $values['admins']);
foreach ($admins as $adm) {
if ($adm != "") {
$group->Admins[]->user_id = $adm;
}
}
//Go through Activity Types
$actvTypes = Doctrine_Query::create()->from('ActivityType')->orderBy("weight")->execute();
foreach ($actvTypes as $atype) {
$atype_key = "atype_" . $atype->atype;
$aSource = new ActivitySource();
$aSource->atype = $atype->atype;
$aSource->target = $values[$atype_key];
$group->ActivitySources[] = $aSource;
}
//populate group
$group->fromArray($values);
//Save Group
$group->save();
var_dump($values, $group->toArray());
//Grab pre-saved venues and tie group_id
$venues = Doctrine_Query::create()->from('Venue')->where("Venue.name LIKE ?", array($values['tmp_id'] . '%'))->execute();
foreach ($venues as $venue) {
$venue->name = str_replace($values['tmp_id'] . "_", "", $venue->name);
$venue->group_id = $group->id;
$venue->save();
}
$this->_helper->flashMessenger("Group added!");
//$this->_helper->redirector('index');
$this->_helper->viewRenderer->setNoRender();
$this->_helper->layout->disableLayout();
}
示例2: isValid
/**
*
* @param array $pParam
* @return boolean
*/
public function isValid($pParam)
{
foreach ($pParam as $f => $v) {
$pParam[$f] = stripslashes($v);
}
return parent::isValid($pParam);
}
示例3: ajouterAction
public function ajouterAction()
{
$form = new Zend_Form();
$form->setMethod('post');
$form->addElement('text', 'TITRE_E', array('label' => 'Titre de l\'émission : ', 'required' => true, 'filters' => array('StringTrim')));
$form->addElement('text', 'THEME', array('label' => 'Theme : ', 'required' => true, 'filters' => array('StringTrim')));
$form->addElement('text', 'ANIMATEURS', array('label' => 'Animateur(s) : ', 'required' => true, 'filters' => array('StringTrim')));
$form->addElement('text', 'DUREE', array('label' => 'Durée de l\'émission : ', 'required' => true, 'filters' => array('Int')));
$form->addElement('text', 'PATH_E', array('label' => 'Lien vers le podcast : ', 'required' => false, 'filters' => array('StringTrim')));
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Ajouter');
$form->addElement($submit);
if ($this->_request->isPost()) {
$formData = $this->_request->getPost();
if ($form->isValid($formData)) {
$dba = Zend_Registry::get('dba');
$datas = array('THEME' => $formData["THEME"], 'ANIMATEURS' => $formData["ANIMATEURS"], 'DUREE' => $formData["DUREE"], 'TITRE_E' => $formData["TITRE_E"], 'PATH_E' => $formData["PATH_E"]);
$dba->beginTransaction();
try {
$dba->insert('EMISSION', $datas);
$dba->commit();
} catch (Exception $e) {
$dba->rollBack();
echo $e->getMessage();
}
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
$this->view->form = $form;
}
示例4: isValid
public function isValid($formData = array())
{
if (isset($formData['property_postcode']) && '' != trim($formData['property_postcode'])) {
$postcode = trim($formData['property_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'];
}
$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['is_foreign_address']) && 'Yes' == $formData['is_foreign_address']) {
$this->getElement('property_postcode')->setRequired(false);
$this->getElement('property_address')->setRequired(false);
}
if (isset($formData['property_postcode'])) {
$this->getElement('property_number_name')->setRequired(false);
}
return parent::isValid($formData);
}
示例5: bookingAction
/** THis is where they pick the duration */
function bookingAction()
{
$this->layout('layout/layout-appointment-summary');
$layoutViewModel = $this->layout();
$progress = new ViewModel(['step' => 3]);
$progress->setTemplate('application/progress');
$layoutViewModel->addChild($progress, 'progress');
$service = $this->serviceDataMapper()->find($this->params('service'));
$durations = array();
foreach ($service['durations'] as $duration) {
$durations[$duration] = $this->durationLabels[$duration];
}
$form = new \Zend_Form();
$form->addElement('radio', 'appointment_duration', array('label' => 'Appointment Duration', 'multiOptions' => $durations, 'separator' => ''));
if ($this->getRequest()->isPost() && $form->isValid($this->params()->fromPost())) {
$url = $this->url()->fromRoute('make-booking', array('action' => 'booking2', 'duration' => $form->getValue('appointment_duration'), 'service' => $this->params('service'), 'day' => $this->params('day')));
$this->redirect()->toUrl($url);
return;
}
$this->viewParams['form'] = $form;
$summary = new ViewModel($this->params()->fromRoute());
$summary->setTemplate('application/summary');
$layoutViewModel->addChild($summary, 'appointment_summary');
$viewModel = new ViewModel($this->viewParams);
$viewModel->setTemplate('application/booking');
return $viewModel;
}
示例6: isValid
public function isValid($postData)
{
if (isset($postData['how_hear']) && $postData['how_hear'] == "Other") {
$this->getElement('other')->setRequired(true);
}
return parent::isValid($postData);
}
示例7: isValid
public function isValid($data)
{
// add email to request data as
// isValid seems to remove any data currently loaded into the form
$email = $this->getElement('email')->getValue();
$data['email'] = $email;
$validationResult = parent::isValid($data);
// Perform login validation
$auth = Zend_Auth::getInstance();
$auth->setStorage(new Zend_Auth_Storage_Session('homelet_customer'));
if ($data['password'] != '') {
// Process login
$customerManager = new Manager_Core_Customer();
$adapter = $customerManager->getAuthAdapter(array('email' => $data['email'], 'password' => $data['password']));
$result = $auth->authenticate($adapter);
if ($result->isValid()) {
$email = $this->getElement('email');
$newCustomer = $customerManager->getCustomerByEmailAddress($email->getValue());
if ($newCustomer->getEmailValidated() !== true) {
$auth->clearIdentity();
$this->setDescription("Unfortunately you haven't validated your email address yet. We've sent you an email which includes a link to validate your My HomeLet account. You'll need to validate your account to continue. If you've not received your validation email or if you're unable to access your account, please call us on 0845 117 6000.");
return false;
}
$storage = $auth->getStorage();
$storage->write($adapter->getResultRowObject(array('title', 'first_name', 'last_name', 'email_address', 'id')));
} else {
$this->setDescription('Your account details are incorrect, please try again');
return false;
}
}
// All valid above, return parents validation result
return $validationResult;
}
示例8: detailAction
public function detailAction()
{
$newsUrl = $this->getRequest()->getParam('url', null);
try {
$news = $this->newsRepository->fetchEntityByUrl($newsUrl);
} catch (\Exception $e) {
throw new \Exception($e->getMessage(), 404);
}
$this->view->headTitle($news->headline);
$this->view->headMeta()->setName('description', $this->_helper->truncate($news->content, 255));
$configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
$commentForm = new \Zend_Form($configForm->comment);
if ($this->getRequest()->isPost()) {
if ($commentForm->isValid($_POST)) {
try {
$values = $commentForm->getValues();
unset($values['csrf']);
unset($values['firstname']);
# SpamDetection
$values['news'] = $news;
$this->commentRepository->saveEntity($values);
$commentForm->reset();
#$this->_helper->systemMessages('notice', 'Kommentar erfolgreich gespeichert');
} catch (\Exception $e) {
$log = $this->getInvokeArg('bootstrap')->log;
$log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
#$this->_helper->systemMessages('error', 'Kommentar konnte nicht gespeichert werden');
}
}
}
$commentForm->setAction('/news/' . $newsUrl);
$this->view->form = $commentForm;
$this->view->news = $news;
}
示例9: editAction
public function editAction()
{
$configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
$userForm = new Zend_Form($configForm->user);
$userId = $this->getRequest()->getParam('id', null);
if ($this->getRequest()->isPost()) {
if ($userForm->isValid($_POST)) {
try {
$values = $userForm->getValues();
unset($values['password_repeat']);
$userId = $this->userRepository->saveEntity($values);
$this->_helper->systemMessages('notice', 'Nutzer erfolgreich gespeichert');
} catch (\Exception $e) {
$log = $this->getInvokeArg('bootstrap')->log;
$log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
$this->_helper->systemMessages('error', 'Nutzer konnte nicht gespeichert werden');
}
}
} else {
try {
$entity = $this->userRepository->fetchEntity($userId);
$userForm->populate($entity->toArray());
} catch (\Exception $e) {
throw new \Exception($e->getMessage(), 404);
}
}
$userForm->setAction('/admin/user/edit/' . $userId);
$this->view->form = $userForm;
}
示例10: loginAction
public function loginAction()
{
$configForm = $this->getInvokeArg('bootstrap')->getResource('configForm');
$loginForm = new \Zend_Form($configForm->login);
if ($this->getRequest()->isPost()) {
if ($loginForm->isValid($_POST)) {
try {
$auth = $this->getInvokeArg('bootstrap')->auth;
$auth->setIdentity($loginForm->getValue('login'))->setCredential($loginForm->getValue('password'));
$result = \Zend_Auth::getInstance()->authenticate($auth);
if ($result->isValid()) {
$this->_redirect('/admin');
} else {
$this->_helper->systemMessages('error', 'Anmeldung verweigert');
}
} catch (\Exception $e) {
$log = $this->getInvokeArg('bootstrap')->log;
$log->log($e->getMessage(), \Zend_Log::ERR, array('trace' => $e->getTraceAsString()));
$this->_helper->systemMessages('error', 'Fehler bei der Anmeldung');
}
}
}
$loginForm->setAction('/login');
$this->view->form = $loginForm;
}
示例11: isValid
public function isValid($data)
{
parent::isValid($data);
$event = new Bc_Form_Event(Bc_Form_Event::FORM_VALIDATE_EVENT, $this);
$event->dispatch();
return !$this->_errorsExist;
}
示例12: removeAction
public function removeAction()
{
$form = new Zend_Form();
$form->setView(new Zend_View());
$form->setMethod('post');
$form->setAction('');
$form->setAttrib('class', 'devel');
$form->setAttrib('title', 'Remove wizard - ' . $this->getRequest()->getParam('name'));
$handleOptions = explode(',', $this->getRequest()->getParam('handles'));
$referenceOptions = explode(',', $this->getRequest()->getParam('references'));
$handleOptionsUsed = explode(',', $this->getRequest()->getParam('handles_used'));
$handleOptionsHidden = $form->createElement('hidden', 'handles', array('decorators' => array('ViewHelper')));
$referenceOptionsHidden = $form->createElement('hidden', 'references', array('decorators' => array('ViewHelper')));
$handleOptionsUsedHidden = $form->createElement('hidden', 'handles_used', array('decorators' => array('ViewHelper')));
$handle = $form->createElement('radio', 'handle', array('label' => 'Handle', 'required' => true, 'multiOptions' => array_combine($handleOptions, $handleOptions), 'description' => 'NOTE: This are the handles that this block appears in: ' . $this->getRequest()->getParam('handles_used')));
$reference = $form->createElement('radio', 'reference', array('label' => 'Reference', 'required' => true, 'multiOptions' => array_combine($referenceOptions, $referenceOptions)));
$name = $form->createElement('text', 'name', array('label' => 'Name', 'required' => true));
$submit = $form->createElement('submit', 'submit', array('label' => 'Submit'));
$form->addElements(array($handleOptionsHidden, $referenceOptionsHidden, $handleOptionsUsedHidden, $handle, $reference, $name, $submit));
if ($form->isValid($this->getRequest()->getParams())) {
$localXmlWriter = Mage::getModel('devel/writer_localxml');
$localXmlWriter->addRemove($form->handle->getValue(), $form->reference->getValue(), $form->name->getValue());
$localXmlWriter->save();
die('DONE. You need to reload to see changes!');
} else {
$this->loadLayout();
$this->getLayout()->getUpdate()->load('devel_layout_wizard');
$this->getLayout()->generateXml();
$this->loadLayout();
$this->getLayout()->getBlock('devel_wizard_form')->setForm($form);
$this->renderLayout();
}
}
示例13: isValid
/**
* Check if the entire form is valid
*
* @return boolean
*/
public function isValid()
{
// Get the form data from the session
$formData = $this->getFormSessionData();
// Validate the form using the session data
return $this->_form->isValid($formData);
}
示例14: isValid
/** @inheritdoc */
public function isValid($data)
{
if ($this->csrfCheck) {
$this->addCsrfProtection();
}
return parent::isValid($data);
}
示例15: isValid
/**
* Proxy to {@link Zend_Form::isValid()}.
*
* Calls {@link self::buildBootstrapErrorDecorators()} for
* {@link parent::isValid()} returning false.
*
* @param array $values
* @return bool
* @throws Zend_Form_Exception
*/
public function isValid($values)
{
$validCheck = parent::isValid($values);
if ($validCheck === false) {
$this->buildBootstrapErrorDecorators();
}
return $validCheck;
}