本文整理汇总了PHP中FrmField类的典型用法代码示例。如果您正苦于以下问题:PHP FrmField类的具体用法?PHP FrmField怎么用?PHP FrmField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了FrmField类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: validate
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;
}
开发者ID:EyesX,项目名称:formidable-forms,代码行数:34,代码来源:FrmEntryValidate.php
示例2: _check_imported_repeating_fields
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');
}
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:8,代码来源:test_FrmXMLHelper.php
示例3: get_all_field_types_for_form_key
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;
}
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:8,代码来源:FrmUnitTest.php
示例4: test_getAll
/**
* @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) {
}
}
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:12,代码来源:test_FrmField.php
示例5: get_all_fields_for_form_key
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;
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:10,代码来源:FrmUnitTest.php
示例6: _get_dynamic_entry_ids
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'];
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:13,代码来源:test_FrmProAppHelper.php
示例7: wpfg_lookup_formidable
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;
}
开发者ID:solepixel,项目名称:wp-forms-grabber,代码行数:14,代码来源:formidable.php
示例8: _set_up_field_object
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;
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:14,代码来源:test_FrmProFieldsHelper.php
示例9: _check_updated_values
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 . '.');
}
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:15,代码来源:test_FrmFormsController.php
示例10: _check_if_form_select_updates
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 :/');
}
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:17,代码来源:test_FrmForm.php
示例11: test_stats_shortcode
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 . '"');
}
}
}
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:17,代码来源:test_FrmProStatisticsController.php
示例12: test_get_all_for_form
/**
* @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.');
}
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:21,代码来源:test_FrmField.php
示例13: test_create
/**
* @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));
}
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:21,代码来源:test_FrmFieldsAjax.php
示例14: update_entry_metas
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();
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:38,代码来源:FrmEntryMeta.php
示例15: migrate_to_6
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);
}
开发者ID:hugocica,项目名称:locomotiva-2016,代码行数:34,代码来源:FrmDb.php
示例16: search_box
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="">— <?php
_e('All Fields', 'formidable');
?>
—</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-">— <?php
_e('All Fields', 'formidable');
?>
—</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;
//.........这里部分代码省略.........
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:101,代码来源:FrmProEntriesListHelper.php
示例17: _check_repeat_options_updated
/**
* @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);
}
开发者ID:amando96,项目名称:formidable-forms,代码行数:11,代码来源:test_FrmProFieldsControllerAjax.php
示例18: __construct
/**
* 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);
}
开发者ID:CalderaWP,项目名称:formworks,代码行数:88,代码来源:settings.php
示例19: set_other_repeating_vals
/**
* 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);
}
}
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:24,代码来源:FrmEntriesHelper.php
示例20: check_value
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;
}
开发者ID:EyesX,项目名称:formidable-forms,代码行数:11,代码来源:FrmFieldsController.php
注:本文中的FrmField类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论