Permalink
Browse files

Adds support to use the isPlainInput setting #635566

  • Loading branch information...
andrelopez committed Jan 7, 2016
1 parent ec6962c commit c6e054b66d45718f7186b5919ed4b53f73c6962f
@@ -175,10 +175,7 @@ public function init()
// Support for displayForm() tag Invisible Captcha output via Hook (if enabled)
craft()->templates->hook('sproutForms.modifyForm', function(&$context) use($self)
{
$sproutFormsSupport = $self->getSettings()->sproutFormsDisplayFormTagOutput;
$hasInvisibleCatpcha = craft()->sproutInvisibleCaptcha->getInvisibleCaptchaField($context['form'], $sproutFormsSupport);
if ($sproutFormsSupport || $hasInvisibleCatpcha)
if ($self->getSettings()->sproutFormsDisplayFormTagOutput)
{
return craft()->sproutInvisibleCaptcha->getProtection();
}
@@ -15,6 +15,7 @@ public function getType()
return 'SproutInvisibleCaptcha_InvisibleCaptcha';
}
public function isPlainInput()
{
return true;
@@ -593,35 +593,4 @@ public function safeOutput($content, $charset = null)
return new \Twig_Markup($content, (string) $charset);
}
/*
* getInvisibleCaptchaField()
*
* @param string $form
*/
public function getInvisibleCaptchaField($form, $sproutFormsSupport = false)
{
// If sproutFormsDisplayFormTagOutput is enabled we don't need validate any field
if(!$sproutFormsSupport)
{
$tabs = $form->getFieldLayout()->getTabs();
foreach ($tabs as $tab)
{
$layoutFields = $tab->getFields();
foreach ($layoutFields as $layoutField)
{
$field = $layoutField->getField()->getFieldType();
$class = get_class($field);
if (get_class($field) === 'Craft\\SproutInvisibleCaptcha_InvisibleCaptchaFieldType')
{
return true;
}
}
}
}
return false;
}
}
@@ -1 +1,3 @@
{# html output handle by the 'sproutForms.modifyForm' hook #}
{% if not craft.sproutinvisiblecaptcha.hasSproutFormsSupport() %}
{{ craft.sproutinvisiblecaptcha.protect() }}
{% endif %}
@@ -51,4 +51,11 @@ public function hasMethodOption( $option )
{
return craft()->sproutInvisibleCaptcha->hasMethodOption($option);
}
public function hasSproutFormsSupport()
{
$settings = craft()->plugins->getPlugin('sproutinvisiblecaptcha')->getSettings();
return $settings->sproutFormsDisplayFormTagOutput;
}
}

0 comments on commit c6e054b

Please sign in to comment.