public static function validate($values, $exclude = false)
 {
     global $wpdb;
     FrmEntry::sanitize_entry_post($values);
     $errors = array();
     if (!isset($values['form_id']) || !isset($values['item_meta'])) {
         $errors['form'] = __('There was a problem with your submission. Please try again.', 'formidable');
         return $errors;
     }
     if (FrmAppHelper::is_admin() && is_user_logged_in() && (!isset($values['frm_submit_entry_' . $values['form_id']]) || !wp_verify_nonce($values['frm_submit_entry_' . $values['form_id']], 'frm_submit_entry_nonce'))) {
         $errors['form'] = __('You do not have permission to do that', 'formidable');
     }
     if (!isset($values['item_key']) || $values['item_key'] == '') {
         $_POST['item_key'] = $values['item_key'] = FrmAppHelper::get_unique_key('', $wpdb->prefix . 'frm_items', 'item_key');
     }
     $where = apply_filters('frm_posted_field_ids', array('fi.form_id' => $values['form_id']));
     // Don't get subfields
     $where['fr.parent_form_id'] = array(null, 0);
     // Don't get excluded fields (like file upload fields in the ajax validation)
     if (!empty($exclude)) {
         $where['fi.type not'] = $exclude;
     }
     $posted_fields = FrmField::getAll($where, 'field_order');
     // Pass exclude value to validate_field function so it can be used for repeating sections
     $args = array('exclude' => $exclude);
     foreach ($posted_fields as $posted_field) {
         self::validate_field($posted_field, $errors, $values, $args);
         unset($posted_field);
     }
     // check for spam
     self::spam_check($exclude, $values, $errors);
     $errors = apply_filters('frm_validate_entry', $errors, $values, compact('exclude'));
     return $errors;
 }
 public function _check_imported_repeating_fields($f, &$fields_tested)
 {
     if (!FrmField::is_repeating_field($f)) {
         return;
     }
     $fields_tested++;
     self::_check_form_select($f, 'rep_sec_form');
 }
 function get_all_field_types_for_form_key($form_key, $expected_field_num, $type)
 {
     $form_id = $this->factory->form->get_id_by_key($form_key);
     $fields = FrmField::get_all_types_in_form($form_id, $type);
     $actual_field_num = count($fields);
     $this->assertEquals($actual_field_num, $expected_field_num, $actual_field_num . ' ' . $type . ' fields were retrieved for ' . $form_key . ' form, but ' . $expected_field_num . ' were expected. This could mean that certain fields were not imported correctly.');
     return $fields;
 }
 /**
  * @covers FrmField::getAll
  */
 function test_getAll()
 {
     $form_id = $this->factory->form->get_id_by_key($this->contact_form_key);
     $fields = FrmField::getAll(array('fi.form_id' => (int) $form_id));
     $this->assertNotEmpty($fields);
     $this->assertTrue(count($fields) >= 7);
     foreach ($fields as $field) {
     }
 }
 function get_all_fields_for_form_key($form_key)
 {
     $field_totals = array($this->all_fields_form_key => 44, $this->create_post_form_key => 10, $this->contact_form_key => 8, $this->repeat_sec_form_key => 3);
     $expected_field_num = isset($field_totals[$form_key]) ? $field_totals[$form_key] : 0;
     $form_id = $this->factory->form->get_id_by_key($form_key);
     $fields = FrmField::get_all_for_form($form_id, '', 'include');
     $actual_field_num = count($fields);
     $this->assertEquals($actual_field_num, $expected_field_num, $actual_field_num . ' fields were retrieved for ' . $form_key . ' form, but ' . $expected_field_num . ' were expected. This could mean that certain fields were not imported correctly.');
     return $fields;
 }
 function _get_dynamic_entry_ids($form_key, $where_field_key, $args)
 {
     // Get where_field
     $where_field = FrmField::getOne($where_field_key);
     // Get all entry IDs for form
     $form_id = $this->factory->form->get_id_by_key($form_key);
     $entry_ids = FrmEntry::getAll(array('it.form_id' => $form_id), '', '', false, false);
     // Prepare the args
     self::_do_prepare_where_args($args, $where_field, $entry_ids);
     // Set new where_val
     self::_do_prepare_dfe_text($args, $where_field);
     return $args['where_val'];
 }
function wpfg_lookup_formidable($form_id)
{
    if (!class_exists('FrmField')) {
        return false;
    }
    $form = FrmField::get_all_for_form($form_id);
    if (is_array($form)) {
        $form = reset($form);
    }
    if (isset($form->form_name) && $form->form_name) {
        return $form->form_name;
    }
    return false;
}
 function _set_up_field_object($test, &$expected_cats, $key)
 {
     // Parent categories
     $args = array('hide_empty' => false, 'taxonomy' => 'category', 'parent' => 0);
     $parent_cats = get_categories($args);
     // Get the correct parent ID(s) for the current test
     $parent_cat_id = self::_get_parent_cat_id($test, $parent_cats, $expected_cats);
     $this->assertNotFalse($parent_cat_id, 'Check if there are at least two parent categories with children and two with no children. Needed for the ' . $test . ' test.');
     // Child field
     $field_id = $this->factory->field->get_id_by_key('child-dynamic-taxonomy');
     $field = FrmField::getOne($field_id);
     $field->field_options['hide_opt'][$key] = $parent_cat_id;
     return $field;
 }
 function _check_updated_values($form_id)
 {
     $fields = FrmField::get_all_for_form($form_id);
     // Compare to posted values
     foreach ($fields as $field) {
         // Check default value
         $posted_val = $_POST['item_meta'][$field->id];
         $actual_val = $field->default_value;
         $this->assertEquals($posted_val, $actual_val, 'The default value was not updated correctly for field ' . $field->field_key . '.');
         // Check calculations
         $posted_val = $_POST['field_options']['use_calc_' . $field->id];
         $actual_val = $field->field_options['use_calc'];
         $this->assertEquals($posted_val, $actual_val, 'The calculation was not updated correctly for field ' . $field->field_key . '.');
     }
 }
 function _check_if_form_select_updates($old_form_id, $new_form_id)
 {
     // Get all repeating sections in both forms
     $old_repeating_sections = FrmField::get_all_types_in_form($old_form_id, 'divider');
     $new_repeating_sections = FrmField::get_all_types_in_form($new_form_id, 'divider');
     if (!$old_repeating_sections) {
         return;
     }
     foreach ($old_repeating_sections as $key => $section) {
         if (!FrmField::is_repeating_field($section)) {
             continue;
         }
         $old_form_select = $section->field_options['form_select'];
         $new_form_select = $new_repeating_sections[$key]->field_options['form_select'];
         $this->assertNotEquals($old_form_select, $new_form_select, 'A form was duplicated, but the form_select was not updated for the repeating section :/');
     }
 }
 function test_stats_shortcode()
 {
     $forms_to_test = array($this->all_fields_form_key => array('493ito', 'p3eiuk', 'uc580i', '4t3qo4', '54tffk', 'endbcl', 'repeating-text'));
     foreach ($forms_to_test as $form_key => $fields) {
         foreach ($fields as $field_key) {
             $field = FrmField::getOne($field_key);
             $value = do_shortcode('[frm-stats id=' . $field->id . ' type=count]');
             $this->assertNotEmpty($value, 'Field ' . $field_key . ' has no saved values');
             if (!empty($field->options)) {
                 $first_option = array_filter($field->options);
                 $first_option = reset($first_option);
                 $filter_by_value = do_shortcode('[frm-stats id=' . $field->id . ' type=count value="' . $first_option . '"]');
                 $this->assertNotEmpty($filter_by_value, 'Field ' . $field_key . ' has no saved values for "' . $first_option . '"');
             }
         }
     }
 }
 /**
  * @covers FrmField::get_all_for_form
  */
 function test_get_all_for_form()
 {
     $forms = array('basic_test' => array('form_key' => $this->contact_form_key, 'count' => 8), 'repeat' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3), 'no_repeat_or_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33), 'repeat_and_embed' => array('form_key' => $this->all_fields_form_key, 'count' => 33 + 3 + 8));
     foreach ($forms as $test => $args) {
         $form_id = FrmForm::getIdByKey($args['form_key']);
         if ($test == 'no_repeat_or_embed') {
             $fields = FrmField::get_all_for_form($form_id, '', 'exclude', 'exclude');
         } else {
             if ($test == 'repeat_and_embed') {
                 $fields = FrmField::get_all_for_form($form_id, '', 'include', 'include');
             } else {
                 $fields = FrmField::get_all_for_form($form_id);
             }
         }
         $this->assertNotEmpty($fields);
         $this->assertEquals($args['count'], count($fields), 'An incorrect number of fields are retrieved with FrmField::get_all_for_form.');
     }
 }
 /**
  * @covers FrmFieldsController::create
  */
 public function test_create()
 {
     wp_set_current_user($this->user_id);
     $this->assertTrue(is_numeric($this->form_id));
     $_POST = array('action' => 'frm_insert_field', 'nonce' => wp_create_nonce('frm_ajax'), 'form_id' => $this->form_id, 'field' => 'text');
     try {
         $this->_handleAjax('frm_insert_field');
     } catch (WPAjaxDieContinueException $e) {
         unset($e);
     }
     global $wpdb;
     $this->field_id = $wpdb->insert_id;
     $this->assertTrue(is_numeric($this->field_id));
     $this->assertNotEmpty($this->field_id);
     // make sure the field exists
     $field = FrmField::getOne($this->field_id);
     $this->assertTrue(is_object($field));
 }
 public static function update_entry_metas($entry_id, $values)
 {
     global $wpdb;
     $prev_values = FrmDb::get_col($wpdb->prefix . 'frm_item_metas', array('item_id' => $entry_id, 'field_id !' => 0), 'field_id');
     foreach ($values as $field_id => $meta_value) {
         $field = false;
         if (!empty($field_id)) {
             $field = FrmField::getOne($field_id);
         }
         // set the value for the file upload field and add new tags (in Pro version)
         $meta_value = apply_filters('frm_prepare_data_before_db', $meta_value, $field_id, $entry_id, compact('field'));
         if ($prev_values && in_array($field_id, $prev_values)) {
             if (is_array($meta_value) && empty($meta_value) || !is_array($meta_value) && trim($meta_value) == '') {
                 // remove blank fields
                 unset($values[$field_id]);
             } else {
                 // if value exists, then update it
                 self::update_entry_meta($entry_id, $field_id, '', $meta_value);
             }
         } else {
             // if value does not exist, then create it
             self::add_entry_meta($entry_id, $field_id, '', $meta_value);
         }
     }
     if (empty($prev_values)) {
         return;
     }
     $prev_values = array_diff($prev_values, array_keys($values));
     if (empty($prev_values)) {
         return;
     }
     // prepare the query
     $where = array('item_id' => $entry_id, 'field_id' => $prev_values);
     FrmDb::get_where_clause_and_values($where);
     // Delete any leftovers
     $wpdb->query($wpdb->prepare('DELETE FROM ' . $wpdb->prefix . 'frm_item_metas ' . $where['where'], $where['values']));
     self::clear_cache();
 }
Example #15
0
    private function migrate_to_6()
    {
        global $wpdb;
        $no_save = array_merge(FrmField::no_save_fields(), array('form', 'hidden', 'user_id'));
        $fields = FrmDb::get_results($this->fields, array('type NOT' => $no_save), 'id, field_options');
        $default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
    <label class="frm_pos_[label_position]">[field_name]
        <span class="frm_required">[required_label]</span>
    </label>
    [input]
    [if description]<div class="frm_description">[description]</div>[/if description]
</div>
DEFAULT_HTML;
        $old_default_html = <<<DEFAULT_HTML
<div id="frm_field_[id]_container" class="form-field [required_class] [error_class]">
    <label class="frm_pos_[label_position]">[field_name]
        <span class="frm_required">[required_label]</span>
    </label>
    [input]
    [if description]<p class="frm_description">[description]</p>[/if description]
</div>
DEFAULT_HTML;
        $new_default_html = FrmFieldsHelper::get_default_html('text');
        foreach ($fields as $field) {
            $field->field_options = maybe_unserialize($field->field_options);
            if (!FrmField::is_option_empty($field, 'custom_html') || $field->field_options['custom_html'] == $default_html || $field->field_options['custom_html'] == $old_default_html) {
                $field->field_options['custom_html'] = $new_default_html;
                $wpdb->update($this->fields, array('field_options' => maybe_serialize($field->field_options)), array('id' => $field->id));
            }
            unset($field);
        }
        unset($default_html, $old_default_html, $fields);
    }
    public function search_box($text, $input_id)
    {
        if (!$this->has_items() && !isset($_REQUEST['s'])) {
            return;
        }
        if (isset($this->params['form'])) {
            $form = FrmForm::getOne($this->params['form']);
        } else {
            $form = FrmForm::get_published_forms(array(), 1);
        }
        if ($form) {
            $field_list = FrmField::getAll(array('fi.form_id' => $form->id, 'fi.type not' => FrmField::no_save_fields()), 'field_order');
        }
        $fid = isset($_REQUEST['fid']) ? esc_attr(stripslashes($_REQUEST['fid'])) : '';
        $input_id = $input_id . '-search-input';
        $search_str = isset($_REQUEST['s']) ? esc_attr(stripslashes($_REQUEST['s'])) : '';
        foreach (array('orderby', 'order') as $get_var) {
            if (!empty($_REQUEST[$get_var])) {
                echo '<input type="hidden" name="' . esc_attr($get_var) . '" value="' . esc_attr($_REQUEST[$get_var]) . '" />';
            }
        }
        ?>
<div class="search-box frm_sidebar">
	<label class="screen-reader-text" for="<?php 
        echo esc_attr($input_id);
        ?>
"><?php 
        echo esc_attr($text);
        ?>
:</label>
	<input type="text" id="<?php 
        echo esc_attr($input_id);
        ?>
" name="s" value="<?php 
        echo esc_attr($search_str);
        ?>
" />
	<?php 
        if (isset($field_list) && !empty($field_list)) {
            ?>
	<select name="fid" class="hide-if-js">
		<option value="">&mdash; <?php 
            _e('All Fields', 'formidable');
            ?>
 &mdash;</option>
		<option value="created_at" <?php 
            selected($fid, 'created_at');
            ?>
><?php 
            _e('Entry creation date', 'formidable');
            ?>
</option>
		<option value="id" <?php 
            selected($fid, 'id');
            ?>
><?php 
            _e('Entry ID', 'formidable');
            ?>
</option>
		<?php 
            foreach ($field_list as $f) {
                ?>
		<option value="<?php 
                echo $f->type == 'user_id' ? 'user_id' : $f->id;
                ?>
" <?php 
                selected($fid, $f->id);
                ?>
><?php 
                echo FrmAppHelper::truncate($f->name, 30);
                ?>
</option>
		<?php 
            }
            ?>
	</select>

	<div class="button dropdown hide-if-no-js">
		<a href="#" id="frm-fid-search" class="frm-dropdown-toggle" data-toggle="dropdown"><?php 
            _e('Search', 'formidable');
            ?>
 <b class="caret"></b></a>
		<ul class="frm-dropdown-menu pull-right" id="frm-fid-search-menu" role="menu" aria-labelledby="frm-fid-search">
			<li><a href="#" id="fid-">&mdash; <?php 
            _e('All Fields', 'formidable');
            ?>
 &mdash;</a></li>
			<li><a href="#" id="fid-created_at"><?php 
            _e('Entry creation date', 'formidable');
            ?>
</a></li>
			<li><a href="#" id="fid-id"><?php 
            _e('Entry ID', 'formidable');
            ?>
</a></li>
			<?php 
            foreach ($field_list as $f) {
                ?>
			<li><a href="#" id="fid-<?php 
                echo $f->type == 'user_id' ? 'user_id' : $f->id;
                ?>
"><?php 
                echo FrmAppHelper::truncate($f->name, 30);
                ?>
</a></li>
			<?php 
                unset($f);
            }
            ?>
		</ul>
	</div>
	<?php 
            submit_button($text, 'button hide-if-js', false, false, array('id' => 'search-submit'));
        } else {
            submit_button($text, 'button', false, false, array('id' => 'search-submit'));
            if (!empty($search_str)) {
                ?>
	<a href="<?php 
                echo esc_url(admin_url('admin.php?page=formidable-entries&frm_action=list&form=' . $form->id));
                ?>
"><?php 
                _e('Reset', 'formidable');
                ?>
</a>
	<?php 
            }
        }
        ?>

</div>
<?php 
    }
 /**
  * @covers update_for_repeat
  */
 function _check_repeat_options_updated($repeating_section, $expected_repeat, $expected_form_select, $msg)
 {
     $new_repeat = FrmField::getOne($repeating_section->id);
     // Check repeat option
     $this->assertEquals($expected_repeat, $new_repeat->field_options['repeat'], 'The repeat option is not updated when a divider is switched to ' . $msg);
     // Check form_select
     $this->assertEmpty($expected_form_select, $new_repeat->field_options['form_select'], 'Form_select not updated when divider is switched to ' . $msg);
 }
Example #18
0
 /**
  * Constructor for class
  *
  * @since 1.0.0
  */
 public function __construct()
 {
     // add admin page
     add_action('admin_menu', array($this, 'add_settings_pages'), 25);
     // save config
     add_action('wp_ajax_frmwks_save_config', array($this, 'save_config'));
     // exporter
     add_action('init', array($this, 'check_exporter'));
     // get forms list
     add_filter('formworks_get_forms', array($this, 'get_forms'));
     add_action('wp_ajax_frmwks_module_data', array($this, 'module_data_loader'));
     if (current_user_can('manage_options')) {
         add_action('wp_ajax_frmwks_rebuild_database', array($this, 'rebuild_database'));
         //add_action( 'wp_ajax_frmwks_reset_form_stats', array( $this, 'reset_form_stats') );
     }
     // create new
     add_action('wp_ajax_frmwks_create_formworks', array($this, 'create_new_formworks'));
     // delete
     add_action('wp_ajax_frmwks_delete_formworks', array($this, 'delete_formworks'));
     add_filter('formworks_stats_field_name', function ($field, $form_prefix, $form_id) {
         switch ($form_prefix) {
             case 'caldera':
                 if (false !== strpos($field, '[')) {
                     $field = strtok($field, '[');
                 }
                 // is CF
                 $form = \Caldera_Forms::get_form($form_id);
                 if (empty($form)) {
                     continue;
                 }
                 if (!empty($form['fields'][$field]['label'])) {
                     $field = $form['fields'][$field]['label'];
                 }
                 break;
             case 'gform':
                 //get gravity form
                 if (!class_exists('RGFormsModel')) {
                     continue;
                 }
                 $form_info = \RGFormsModel::get_form($form_id);
                 break;
             case 'ninja':
                 //get ninja form
                 if (!function_exists('Ninja_Forms')) {
                     continue;
                 }
                 $form_name = Ninja_Forms()->form($form_id)->get_setting('form_title');
                 $form_id = $form_id;
                 break;
             case 'cf7':
                 //get contact form 7
                 if (!class_exists('WPCF7_ContactForm')) {
                     continue;
                 }
                 $cf7form = \WPCF7_ContactForm::get_instance($form_id);
                 $form_name = $cf7form->title();
                 $form_id = $cf7form->id();
                 break;
             case 'frmid':
                 if (!class_exists('FrmForm')) {
                     continue;
                 }
                 $field_id = (int) strtok(str_replace('item_meta[', '', $field), ']');
                 $form_field = \FrmField::getOne($field_id);
                 $field = $form_field->name;
                 if (!empty($form_field->description) && $form_field->description != $form_field->name) {
                     $field .= ':' . $form_field->description;
                 }
                 break;
             case 'jp':
                 $form_post = get_post($form_id);
                 if (empty($form_post)) {
                     continue;
                 }
                 $field = ucwords(str_replace('g' . $form_id . '-', '', $field));
                 break;
             default:
                 //no idea what this is or the form plugin was disabled.
                 break;
         }
         return $field;
     }, 10, 3);
 }
 /**
  * Sets radio or checkbox value equal to "other" value if it is set - FOR REPEATING SECTIONS
  *
  * @since 2.0
  *
  * @param object $field
  * @param string|array $value
  * @param array $args
  */
 public static function set_other_repeating_vals($field, &$value, &$args)
 {
     if (!$args['parent_field_id']) {
         return;
     }
     // Check if there are any other posted "other" values for this field
     if (FrmField::is_option_true($field, 'other') && isset($_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id])) {
         // Save original value
         $args['temp_value'] = $value;
         $args['other'] = true;
         $other_vals = $_POST['item_meta'][$args['parent_field_id']][$args['key_pointer']]['other'][$field->id];
         // Set the validation value now
         self::set_other_validation_val($value, $other_vals, $field, $args);
     }
 }
 public static function check_value($opt, $opt_key, $field)
 {
     if (is_array($opt)) {
         if (FrmField::is_option_true($field, 'separate_value')) {
             $opt = isset($opt['value']) ? $opt['value'] : (isset($opt['label']) ? $opt['label'] : reset($opt));
         } else {
             $opt = isset($opt['label']) ? $opt['label'] : reset($opt);
         }
     }
     return $opt;
 }
 private function get_column_value($item, &$val)
 {
     $col_name = $this->column_name;
     if (strpos($col_name, 'frmsep_') === 0) {
         $sep_val = true;
         $col_name = str_replace('frmsep_', '', $col_name);
     } else {
         $sep_val = false;
     }
     if (strpos($col_name, '-_-')) {
         list($col_name, $embedded_field_id) = explode('-_-', $col_name);
     }
     $field = FrmField::getOne($col_name);
     if (!$field) {
         return;
     }
     $atts = array('type' => $field->type, 'truncate' => true, 'post_id' => $item->post_id, 'entry_id' => $item->id, 'embedded_field_id' => 0);
     if ($sep_val) {
         $atts['saved_value'] = true;
     }
     if (isset($embedded_field_id)) {
         $atts['embedded_field_id'] = $embedded_field_id;
         unset($embedded_field_id);
     }
     $val = FrmEntriesHelper::prepare_display_value($item, $field, $atts);
 }
 function get_id_by_key($field_key)
 {
     return FrmField::get_id_by_key($field_key);
 }
Example #23
0
    <option value="not LIKE" <?php 
selected($condition['hide_field_cond'], 'not LIKE');
?>
><?php 
_e('not like', 'formidable');
?>
 &nbsp;</option>
</select>

<span id="frm_show_selected_values_<?php 
echo esc_attr($key . '_' . $meta_name);
?>
">
<?php 
if ($condition['hide_field'] && is_numeric($condition['hide_field'])) {
    $new_field = FrmField::getOne($condition['hide_field']);
}
$val = isset($condition['hide_opt']) ? $condition['hide_opt'] : '';
if (!isset($field)) {
    $field = array('hide_opt' => array($meta_name => $val));
}
$field_name = $names['hide_opt'];
require FrmAppHelper::plugin_path() . '/pro/classes/views/frmpro-fields/field-values.php';
?>
</span>
<a href="javascript:void(0)" class="frm_remove_tag frm_icon_font" data-removeid="<?php 
echo esc_attr($id);
?>
" <?php 
echo !empty($showlast) ? 'data-showlast="' . esc_attr($showlast) . '"' : '';
?>
Example #24
0
    ?>
</a> |</li>
	        <li><a href="javascript:void(0)" class="frmkeys"><?php 
    _e('Keys', 'formidable');
    ?>
</a></li>
	    </ul>
	    <ul class="alignleft"><li><?php 
    _e('Fields from your form', 'formidable');
    ?>
:</li></ul>
	    <ul class="frm_code_list frm_full_width">
		    <?php 
    if (!empty($fields)) {
        foreach ($fields as $f) {
            if (FrmField::is_no_save_field($f->type) || $f->type == 'data' && (!isset($f->field_options['data_type']) || $f->field_options['data_type'] == 'data' || $f->field_options['data_type'] == '')) {
                continue;
            }
            ?>
                <li>
                    <a href="javascript:void(0)" class="frmids alignright frm_insert_code" data-code="if <?php 
            echo esc_attr($f->id);
            ?>
]<?php 
            esc_attr_e('Conditional text here', 'formidable');
            ?>
[/if <?php 
            echo esc_attr($f->id);
            ?>
">[if <?php 
            echo (int) $f->id;
?>
            </ul>
            <div class="clear"></div>
            <hr/>
			<ul <?php 
echo apply_filters('frm_drag_field_class', '');
?>
 style="margin-top:2px;">
				<li><?php 
FrmTipsHelper::pro_tip('get_builder_tip');
?>
</li>
<?php 
$col_class = 'frm_col_one';
$no_allow_class = apply_filters('frm_noallow_class', 'frm_noallow');
foreach (FrmField::pro_field_selection() as $field_key => $field_type) {
    if (is_array($field_type)) {
        $field_label = $field_type['name'];
        if (isset($field_type['switch_from'])) {
            continue;
        }
        ?>
				<li class="frmbutton button <?php 
        echo esc_attr($col_class . ' ' . $no_allow_class . ' frm_t' . $field_key);
        ?>
 dropdown" id="<?php 
        echo esc_attr($field_key);
        ?>
">
	                <a href="#" id="frm-<?php 
        echo esc_attr($field_key);
 public static function &filter_email_value($value, $meta, $entry, $atts = array())
 {
     $frm_field = new FrmField();
     $field = $frm_field->getOne($meta->field_id);
     if (!$field) {
         return $value;
     }
     $value = self::filter_display_value($value, $field, $atts);
     return $value;
 }
 private static function fields_to_values($form_id, array &$values)
 {
     $form = FrmForm::getOne($form_id);
     $values = array('fields' => array(), 'id' => $form->id);
     $fields = FrmField::get_all_for_form($form->id);
     foreach ($fields as $k => $f) {
         $f = (array) $f;
         $opts = (array) $f['field_options'];
         $f = array_merge($opts, $f);
         if (!isset($f['post_field'])) {
             $f['post_field'] = '';
         }
         $values['fields'][] = $f;
         unset($k, $f);
     }
     return $form;
 }
Example #28
0
                ?>
        </ul>
    <?php 
            }
        } else {
            if ($field['type'] == 'select') {
                if (isset($field['post_field']) && $field['post_field'] == 'post_category') {
                    echo FrmFieldsHelper::dropdown_categories(array('name' => $field_name, 'field' => $field));
                } else {
                    ?>
	<select name="<?php 
                    echo esc_attr($field_name) . (FrmField::is_option_true($field, 'multiple') ? '[]' : '');
                    ?>
" <?php 
                    echo FrmField::is_option_true($field, 'size') ? 'class="auto_width"' : '';
                    echo FrmField::is_option_true($field, 'multiple') ? ' multiple="multiple"' : '';
                    ?>
 >
		<?php 
                    foreach ($field['options'] as $opt_key => $opt) {
                        $field_val = apply_filters('frm_field_value_saved', $opt, $opt_key, $field);
                        $opt = apply_filters('frm_field_label_seen', $opt, $opt_key, $field);
                        $selected = $field['default_value'] == $field_val || FrmFieldsHelper::get_other_val(array('opt_key', 'field')) ? ' selected="selected"' : '';
                        ?>
            <option value="<?php 
                        echo esc_attr($field_val);
                        ?>
"<?php 
                        echo $selected;
                        ?>
><?php 
Example #29
0
 /**
  * Keep track of imported repeating fields and embedded forms
  *
  * @since 2.0.09
  * @param array $f - field array
  * @param int $repeat_field_id
  * @param array $repeat_fields - pass by reference
  */
 private static function track_repeating_fields($f, $repeat_field_id, &$repeat_fields)
 {
     if ($f['type'] == 'divider' && FrmField::is_option_true($f['field_options'], 'repeat') || $f['type'] == 'form') {
         $old_form_id = trim($f['field_options']['form_select']);
         if (!isset($repeat_fields[$old_form_id])) {
             $repeat_fields[$old_form_id] = array();
         }
         $repeat_fields[$old_form_id][] = $repeat_field_id;
     }
 }
 /**
  * Get the values for Dynamic List fields based on the conditional logic settings
  *
  * @since 2.0.08
  * @param object $field
  * @param object $entry
  * @param string|array|int $field_value, pass by reference
  */
 public static function get_dynamic_list_values($field, $entry, &$field_value)
 {
     // Exit now if a value is already set, field type is not Dynamic List, or conditional logic is not set
     if ($field_value || $field->type != 'data' || !FrmProField::is_list_field($field) || !isset($field->field_options['hide_field'])) {
         return;
     }
     $field_value = array();
     foreach ((array) $field->field_options['hide_field'] as $hfield) {
         if (isset($entry->metas[$hfield])) {
             // Check if field in conditional logic is a Dynamic field
             $cl_field_type = FrmField::get_type($hfield);
             if ($cl_field_type == 'data') {
                 $cl_field_val = maybe_unserialize($entry->metas[$hfield]);
                 if (is_array($cl_field_val)) {
                     $field_value += $cl_field_val;
                 } else {
                     $field_value[] = $cl_field_val;
                 }
             }
         }
     }
 }