コード例 #1
0
ファイル: SproutFieldsPlugin.php プロジェクト: andyra/tes
 public function init()
 {
     Craft::import('plugins.sproutfields.contracts.SproutFieldsBaseField');
     Craft::import('plugins.sproutfields.integrations.sproutforms.fields.*');
     Craft::import('plugins.sproutfields.integrations.sproutimport.fields.*');
     craft()->on('sproutForms.beforePopulateEntry', array(sproutFields()->emailSelect, 'handleUnobfuscateEmailAddresses'));
 }
コード例 #2
0
 /**
  * Validates submitted value beyond the checks
  * that were assumed based on the content attribute.
  *
  * @param array $value
  *
  * @return true|string|array
  */
 public function validate($value)
 {
     $settings = $this->model->settings;
     if (!sproutFields()->link->validate($value, $this->model)) {
         return craft()->sproutFields_linkField->getErrorMessage($this->model->name, $settings);
     }
     return true;
 }
コード例 #3
0
 public function prepSettings($settings)
 {
     // Clear input message when checkbox is uncheck
     if (empty($settings['customPatternToggle'])) {
         // Set mask back to default when uncheck
         $default = sproutFields()->phone->getDefaultMask();
         $settings['mask'] = $default;
         $settings['customPatternErrorMessage'] = '';
     }
     return $settings;
 }
コード例 #4
0
 /**
  * Validates our fields submitted value beyond the checks
  * that were assumed based on the content attribute.
  *
  * Returns 'true' or any custom validation errors.
  *
  * @param array $value
  *
  * @return true|string|array
  */
 public function validate($value)
 {
     $customPattern = $this->model->settings['customPattern'];
     $checkPattern = $this->model->settings['customPatternToggle'];
     if (!sproutFields()->email->validateEmailAddress($value, $customPattern, $checkPattern)) {
         return sproutFields()->email->getErrorMessage($this->model->name, $this->model->settings);
     }
     $uniqueEmail = $this->model->settings['uniqueEmail'];
     if ($uniqueEmail && !sproutFields()->email->validateUniqueEmailAddress($value, $this->element, $this->model)) {
         return Craft::t($this->model->name . ' must be a unique email.');
     }
     return true;
 }