当前位置: 首页>>代码示例>>PHP>>正文


PHP TextField::hasErrors方法代码示例

本文整理汇总了PHP中TextField::hasErrors方法的典型用法代码示例。如果您正苦于以下问题:PHP TextField::hasErrors方法的具体用法?PHP TextField::hasErrors怎么用?PHP TextField::hasErrors使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在TextField的用法示例。


在下文中一共展示了TextField::hasErrors方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testRegexpPrice

 public function testRegexpPrice()
 {
     \Input::setPost('test_rgxp_price', 'foobar');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertTrue($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20.00');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '-20');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
     \Input::setPost('test_rgxp_price', '20.-');
     $objWidget = new \TextField(array('name' => 'test_rgxp_price'));
     $objWidget->rgxp = 'price';
     $objWidget->validate();
     $this->assertFalse($objWidget->hasErrors());
     unset($objWidget);
 }
开发者ID:ralfhartmann,项目名称:isotope_core,代码行数:33,代码来源:IsotopeTest.php

示例2: validator

 /**
  * @param mixed $varInput
  * @return mixed
  */
 protected function validator($varInput)
 {
     // Get language id
     $intId = $this->activeRecord ? $this->activeRecord->{$this->strName} : $GLOBALS['TL_CONFIG'][$this->strName];
     // Check if translation fields should not be empty saved
     if (!$GLOBALS['TL_CONFIG']['dontfillEmptyTranslationFields']) {
         // Fill all empty fields with the content of the fallback field
         $varInput = \TranslationFieldsWidgetHelper::addFallbackValueToEmptyField($varInput);
         parent::validator($varInput);
     } else {
         // Check only the first field
         parent::validator($varInput[key($varInput)]);
     }
     // Check if array
     if (is_array($varInput)) {
         if (!parent::hasErrors()) {
             // Save values and return fid
             return \TranslationFieldsWidgetHelper::saveValuesAndReturnFid($varInput, $intId);
         }
     }
     return $intId;
 }
开发者ID:craffft,项目名称:contao-translation-fields,代码行数:26,代码来源:TranslationTextField.php

示例3: getDeadlineWidget

	/**
	 * Return the deadline widget as object
	 * @param mixed
	 * @return Widget
	 */
	protected function getDeadlineWidget($value=null)
	{
		$widget = new TextField();

		$widget->id = 'deadline';
		$widget->name = 'deadline';
		$widget->mandatory = true;
		$widget->rgxp = 'date';
		$widget->value = $value;

		$widget->label = $GLOBALS['TL_LANG']['tl_task']['deadline'][0];

		if ($GLOBALS['TL_CONFIG']['showHelp'] && $GLOBALS['TL_LANG']['tl_task']['deadline'][1] != '')
		{
			$widget->help = $GLOBALS['TL_LANG']['tl_task']['deadline'][1];
		}

		// Valiate input
		if ($this->Input->post('FORM_SUBMIT') == 'tl_tasks')
		{
			$widget->validate();

			if ($widget->hasErrors())
			{
				$this->blnSave = false;
			}
		}

		return $widget;
	}
开发者ID:narrenfrei,项目名称:core,代码行数:35,代码来源:ModuleTasks.php

示例4: handle

 /**
  * {@inheritdoc}
  */
 public function handle(\Input $input)
 {
     /** @var RootPackage $rootPackage */
     $rootPackage = $this->composer->getPackage();
     /** @var Config $config */
     $config = $this->composer->getConfig();
     $minimumStability = new \SelectMenu(array('id' => 'minimum-stability', 'name' => 'minimum-stability', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_minimum_stability'][1], 'options' => array(array('value' => 'stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_stable']), array('value' => 'RC', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_rc']), array('value' => 'beta', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_beta']), array('value' => 'alpha', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_alpha']), array('value' => 'dev', 'label' => $GLOBALS['TL_LANG']['composer_client']['stability_dev'])), 'value' => $rootPackage->getMinimumStability(), 'class' => 'minimum-stability', 'required' => true));
     $preferStable = new \CheckBox(array('id' => 'prefer-stable', 'name' => 'prefer-stable', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][1], 'options' => array(array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_prefer_stable'][0])), 'value' => $rootPackage->getPreferStable(), 'class' => 'prefer-stable', 'required' => true));
     $preferredInstall = new \SelectMenu(array('id' => 'preferred-install', 'name' => 'preferred-install', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_preferred_install'][1], 'options' => array(array('value' => 'source', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_source']), array('value' => 'dist', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_dist']), array('value' => 'auto', 'label' => $GLOBALS['TL_LANG']['composer_client']['install_auto'])), 'value' => $config->get('preferred-install'), 'class' => 'preferred-install', 'required' => true));
     $configGithubOauth = $config->get('github-oauth');
     $githubOauth = new \TextField(array('id' => 'github-oauth', 'name' => 'github-oauth', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_github_oauth'][1], 'value' => $configGithubOauth['github.com'], 'class' => 'github-oauth'));
     $discardChanges = new \SelectMenu(array('id' => 'discard-changes', 'name' => 'discard-changes', 'label' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][0], 'description' => $GLOBALS['TL_LANG']['composer_client']['widget_discard_changes'][1], 'options' => array(array('value' => '', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_no']), array('value' => '1', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_yes']), array('value' => 'stash', 'label' => $GLOBALS['TL_LANG']['composer_client']['discard_changes_stash'])), 'value' => (string) $config->get('discard-changes'), 'class' => 'github-oauth'));
     if ($input->post('FORM_SUBMIT') == 'tl_composer_settings') {
         $doSave = false;
         $json = new JsonFile(TL_ROOT . '/' . $this->configPathname);
         $config = $json->read();
         $minimumStability->validate();
         $preferStable->validate();
         $preferredInstall->validate();
         $githubOauth->validate();
         $discardChanges->validate();
         if (!$minimumStability->hasErrors()) {
             $config['minimum-stability'] = $minimumStability->value;
             $doSave = true;
         }
         if (!$preferStable->hasErrors()) {
             $config['prefer-stable'] = (bool) $preferStable->value;
             $doSave = true;
         }
         if (!$preferredInstall->hasErrors()) {
             $config['config']['preferred-install'] = $preferredInstall->value;
             $doSave = true;
         }
         if (!$githubOauth->hasErrors()) {
             if ($githubOauth->value) {
                 $config['config']['github-oauth']['github.com'] = $githubOauth->value;
             } else {
                 unset($config['config']['github-oauth']['github.com']);
                 if (empty($config['config']['github-oauth'])) {
                     unset($config['config']['github-oauth']);
                 }
             }
             $doSave = true;
         }
         if (!$discardChanges->hasErrors()) {
             if ($discardChanges->value) {
                 $config['config']['discard-changes'] = $discardChanges->value == 'stash' ? 'stash' : (bool) $discardChanges->value;
             } else {
                 unset($config['config']['discard-changes']);
             }
             $doSave = true;
         }
         if ($doSave) {
             // make a backup
             copy(TL_ROOT . '/' . $this->configPathname, TL_ROOT . '/' . $this->configPathname . '~');
             // update config file
             $json->write($config);
         }
         $this->redirect('contao/main.php?do=composer&settings=dialog');
     }
     $template = new \BackendTemplate('be_composer_client_settings');
     $template->composer = $this->composer;
     $template->minimumStability = $minimumStability;
     $template->preferStable = $preferStable;
     $template->preferredInstall = $preferredInstall;
     $template->githubOauth = $githubOauth;
     $template->discardChanges = $discardChanges;
     return $template->parse();
 }
开发者ID:contao-community-alliance,项目名称:composer-client,代码行数:72,代码来源:SettingsController.php


注:本文中的TextField::hasErrors方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。