code/Extension/FormSpamProtectionExtension.php
public function enableSpamProtection($options = array())
    {

        // captcha form field name (must be unique)
        if (isset($options['name'])) {
            $name = $options['name'];
        } else {
            $name = $this->config()->get('field_name');
        }

        // captcha field title
        if (isset($options['title'])) {
            $title = $options['title'];
        } else {
            $title = '';
        }

        // set custom mapping on this form
        $protector = self::get_protector($options);

        if (isset($options['mapping'])) {
            $protector->setFieldMapping($options['mapping']);
        }

        if ($protector) {
            // add the form field
            if ($field = $protector->getFormField($name, $title)) {
                $field->setForm($this->owner);

                // Add before field specified by insertBefore
                $inserted = false;
                if (!empty($options['insertBefore'])) {
                    $inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']);
                }
                if (!$inserted) {
                    // Add field to end if not added already
                    $this->owner->Fields()->push($field);
                }
            }
        }

        return $this->owner;
    }
public function enableSpamProtection($options = array())
    {

        // captcha form field name (must be unique)
        if (isset($options['name'])) {
            $name = $options['name'];
        } else {
            $name = $this->config()->get('field_name');
        }

        // captcha field title
        if (isset($options['title'])) {
            $title = $options['title'];
        } else {
            $title = '';
        }

        // set custom mapping on this form
        $protector = self::get_protector($options);

        if (isset($options['mapping'])) {
            $protector->setFieldMapping($options['mapping']);
        }

        if ($protector) {
            // add the form field
            if ($field = $protector->getFormField($name, $title)) {
                $field->setForm($this->owner);

                // Add before field specified by insertBefore
                $inserted = false;
                if (!empty($options['insertBefore'])) {
                    $inserted = $this->owner->Fields()->insertBefore($field, $options['insertBefore']);
                }
                if (!$inserted) {
                    // Add field to end if not added already
                    $this->owner->Fields()->push($field);
                }
            }
        }

        return $this->owner;
    }
public function enableSpamProtection ( $ options = array ( ) ) { // captcha form field name (must be unique) if ( isset ( $ options [ 'name' ] ) ) { $ name = $ options [ 'name' ] ; } else { $ name = $ this -> config ( ) -> get ( 'field_name' ) ; } // captcha field title if ( isset ( $ options [ 'title' ] ) ) { $ title = $ options [ 'title' ] ; } else { $ title = '' ; } // set custom mapping on this form $ protector = self :: get_protector ( $ options ) ; if ( isset ( $ options [ 'mapping' ] ) ) { $ protector -> setFieldMapping ( $ options [ 'mapping' ] ) ; } if ( $ protector ) { // add the form field if ( $ field = $ protector -> getFormField ( $ name , $ title ) ) { $ field -> setForm ( $ this -> owner ) ; // Add before field specified by insertBefore $ inserted = false ; if ( ! empty ( $ options [ 'insertBefore' ] ) ) { $ inserted = $ this -> owner -> Fields ( ) -> insertBefore ( $ field , $ options [ 'insertBefore' ] ) ; } if ( ! $ inserted ) { // Add field to end if not added already $ this -> owner -> Fields ( ) -> push ( $ field ) ; } } } return $ this -> owner ; }
Activates the spam protection module.

@param array $options
@return Object
Activates the spam protection module .