当前位置: 首页>>代码示例>>PHP>>正文


PHP FrmFieldsHelper::get_default_field_opts方法代码示例

本文整理汇总了PHP中FrmFieldsHelper::get_default_field_opts方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmFieldsHelper::get_default_field_opts方法的具体用法?PHP FrmFieldsHelper::get_default_field_opts怎么用?PHP FrmFieldsHelper::get_default_field_opts使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FrmFieldsHelper的用法示例。


在下文中一共展示了FrmFieldsHelper::get_default_field_opts方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: setup_edit_vars

 function setup_edit_vars($record)
 {
     global $frm_entry_meta, $frm_form;
     $values = array();
     $record->field_options = maybe_unserialize($record->field_options);
     $values['id'] = $record->id;
     $values['form_id'] = $record->form_id;
     foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default) {
         $values[$var] = htmlspecialchars(stripslashes(FrmAppHelper::get_param($var, $default)));
     }
     $values['form_name'] = $record->form_id ? $frm_form->getName($record->form_id) : '';
     foreach (array('field_key' => $record->field_key, 'type' => $record->type, 'default_value' => $record->default_value, 'field_order' => $record->field_order, 'required' => $record->required) as $var => $default) {
         $values[$var] = FrmAppHelper::get_param($var, $default);
     }
     $values['options'] = stripslashes_deep(maybe_unserialize($record->options));
     $values['field_options'] = $record->field_options;
     $defaults = FrmFieldsHelper::get_default_field_opts($values['type'], $record, true);
     if ($values['type'] == 'captcha') {
         global $frm_settings;
         $defaults['invalid'] = $frm_settings->re_msg;
     }
     foreach ($defaults as $opt => $default) {
         $values[$opt] = isset($record->field_options[$opt]) ? $record->field_options[$opt] : $default;
     }
     $values['custom_html'] = isset($record->field_options['custom_html']) ? stripslashes($record->field_options['custom_html']) : FrmFieldsHelper::get_default_html($record->type);
     return apply_filters('frm_setup_edit_field_vars', $values, $values['field_options']);
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:27,代码来源:FrmFieldsHelper.php

示例2: setup_new_vars

 public static function setup_new_vars($fields, $form = '', $reset = false, $args = array())
 {
     global $frm_vars;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = FrmAppHelper::get_post_param($var, $default);
     }
     $values['fields'] = array();
     if (empty($fields)) {
         return apply_filters('frm_setup_new_entry', $values);
     }
     foreach ((array) $fields as $field) {
         $new_value = self::get_field_value_for_new_entry($field, $reset);
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id, 'parent_form_id' => isset($args['parent_form_id']) ? $args['parent_form_id'] : $field->form_id);
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         $opt_defaults['required_indicator'] = '';
         $opt_defaults['original_type'] = $field->type;
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
             unset($opt, $default_opt);
         }
         unset($opt_defaults);
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
         }
         $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
         $field_array = array_merge($field->field_options, $field_array);
         $values['fields'][] = $field_array;
         if (!$form || !isset($form->id)) {
             $form = FrmForm::getOne($field->form_id);
         }
     }
     $form->options = maybe_unserialize($form->options);
     if (is_array($form->options)) {
         foreach ($form->options as $opt => $value) {
             $values[$opt] = FrmAppHelper::get_post_param($opt, $value);
             unset($opt, $value);
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $frm_settings = FrmAppHelper::get_settings();
     $form_defaults['custom_style'] = $frm_settings->load_style != 'none';
     $values = array_merge($form_defaults, $values);
     return apply_filters('frm_setup_new_entry', $values);
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:45,代码来源:FrmEntriesHelper.php

示例3: setup_new_vars

 public static function setup_new_vars($type = '', $form_id = '')
 {
     global $frm_settings;
     $defaults = FrmFieldsHelper::get_default_field_opts($type, $form_id);
     $defaults['field_options']['custom_html'] = FrmFieldsHelper::get_default_html($type);
     $values = array();
     foreach ($defaults as $var => $default) {
         if ($var == 'field_options') {
             $values['field_options'] = array();
             foreach ($default as $opt_var => $opt_default) {
                 $values['field_options'][$opt_var] = $opt_default;
                 unset($opt_var);
                 unset($opt_default);
             }
         } else {
             $values[$var] = $default;
         }
         unset($var);
         unset($default);
     }
     if ($type == 'radio' || $type == 'checkbox') {
         $values['options'] = serialize(array(__('Option 1', 'formidable'), __('Option 2', 'formidable')));
     } else {
         if ($type == 'select') {
             $values['options'] = serialize(array('', __('Option 1', 'formidable')));
         } else {
             if ($type == 'textarea') {
                 $values['field_options']['max'] = '5';
             } else {
                 if ($type == 'captcha') {
                     $values['invalid'] = $frm_settings->re_msg;
                 }
             }
         }
     }
     $fields = self::field_selection();
     $fields = array_merge($fields, self::pro_field_selection());
     if (isset($fields[$type])) {
         $values['name'] = $fields[$type];
     }
     unset($fields);
     return $values;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:43,代码来源:FrmFieldsHelper.php

示例4: fill_field_opts

 private static function fill_field_opts($field, array &$field_array, $args)
 {
     $post_values = $args['post_values'];
     $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
     foreach ($opt_defaults as $opt => $default_opt) {
         $field_array[$opt] = $post_values && isset($post_values['field_options'][$opt . '_' . $field->id]) ? maybe_unserialize($post_values['field_options'][$opt . '_' . $field->id]) : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
         if ($opt == 'blank' && $field_array[$opt] == '') {
             $field_array[$opt] = $args['frm_settings']->blank_msg;
         } else {
             if ($opt == 'invalid' && $field_array[$opt] == '') {
                 if ($args['field_type'] == 'captcha') {
                     $field_array[$opt] = $args['frm_settings']->re_msg;
                 } else {
                     $field_array[$opt] = sprintf(__('%s is invalid', 'formidable'), $field_array['name']);
                 }
             }
         }
     }
     if ($field_array['custom_html'] == '') {
         $field_array['custom_html'] = FrmFieldsHelper::get_default_html($args['field_type']);
     }
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:22,代码来源:FrmAppHelper.php

示例5: setup_edit_vars

 function setup_edit_vars($record, $table, $fields = '', $default = false)
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_form, $frm_settings, $frm_sidebar_width;
     $values = array();
     $values['id'] = $record->id;
     foreach (array('name' => $record->name, 'description' => $record->description) as $var => $default_val) {
         $values[$var] = stripslashes(FrmAppHelper::get_param($var, $default_val));
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop($values['description']);
     }
     $values['fields'] = array();
     if ($fields) {
         foreach ($fields as $field) {
             $field->field_options = stripslashes_deep(maybe_unserialize($field->field_options));
             if ($default) {
                 $meta_value = $field->default_value;
             } else {
                 if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) {
                     $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
                 } else {
                     if (isset($record->metas)) {
                         $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
                     } else {
                         $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id);
                     }
                 }
             }
             $field_type = isset($_POST['field_options']['type_' . $field->id]) ? $_POST['field_options']['type_' . $field->id] : $field->type;
             $new_value = isset($_POST['item_meta'][$field->id]) ? $_POST['item_meta'][$field->id] : $meta_value;
             $new_value = maybe_unserialize($new_value);
             if (is_array($new_value)) {
                 $new_value = stripslashes_deep($new_value);
             }
             $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => stripslashes_deep(maybe_unserialize($field->default_value)), 'name' => stripslashes($field->name), 'description' => stripslashes($field->description), 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => stripslashes_deep(maybe_unserialize($field->options)), 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
             /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
                   foreach((array)$field_array['options'] as $opt_key => $opt){
                       if(!is_array($opt))
                           $field_array['options'][$opt_key] = array('label' => $opt);
                       unset($opt);
                       unset($opt_key);
                   }
               }*/
             $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
             foreach ($opt_defaults as $opt => $default_opt) {
                 $field_array[$opt] = ($_POST and isset($_POST['field_options'][$opt . '_' . $field->id])) ? $_POST['field_options'][$opt . '_' . $field->id] : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
                 if ($opt == 'blank' and $field_array[$opt] == '') {
                     $field_array[$opt] = __('This field cannot be blank', 'formidable');
                 } else {
                     if ($opt == 'invalid' and $field_array[$opt] == '') {
                         if ($field_type == 'captcha') {
                             $field_array[$opt] = $frm_settings->re_msg;
                         } else {
                             $field_array[$opt] = $field_array['name'] . ' ' . __('is invalid', 'formidable');
                         }
                     }
                 }
             }
             unset($opt_defaults);
             if ($field_array['custom_html'] == '') {
                 $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
             }
             if ($field_array['size'] == '') {
                 $field_array['size'] = $frm_sidebar_width;
             }
             $values['fields'][] = apply_filters('frm_setup_edit_fields_vars', stripslashes_deep($field_array), $field, $values['id']);
             unset($field);
         }
     }
     if ($table == 'entries') {
         $form = $frm_form->getOne($record->form_id);
     } else {
         if ($table == 'forms') {
             $form = $frm_form->getOne($record->id);
         }
     }
     if ($form) {
         $form->options = maybe_unserialize($form->options);
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 $values[$opt] = FrmAppHelper::get_param($opt, $value);
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $form_defaults['email_to'] = '';
     //options to allow blank answers
     foreach (array('email_to', 'reply_to', 'reply_to_name') as $opt) {
         if (!isset($values[$opt])) {
             $values[$opt] = ($_POST and isset($_POST['options'][$opt])) ? $_POST['options'][$opt] : $form_defaults[$opt];
             unset($form_defaults[$opt]);
             unset($opt);
         }
     }
     //don't allow blank answers
     foreach ($form_defaults as $opt => $default) {
//.........这里部分代码省略.........
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:101,代码来源:FrmAppHelper.php

示例6: setup_new_vars

 function setup_new_vars($fields, $form = '', $reset = false)
 {
     global $frm_form, $frm_settings, $frm_sidebar_width;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = stripslashes(FrmAppHelper::get_post_param($var, $default));
     }
     $values['fields'] = array();
     if ($fields) {
         foreach ($fields as $field) {
             $field->field_options = maybe_unserialize($field->field_options);
             $default = $field->default_value;
             if ($reset) {
                 $new_value = $default;
             } else {
                 $new_value = ($_POST and isset($_POST['item_meta'][$field->id]) and $_POST['item_meta'][$field->id] != '') ? $_POST['item_meta'][$field->id] : $default;
             }
             $is_default = $new_value == $default ? true : false;
             $new_value = stripslashes_deep(maybe_unserialize($new_value));
             if (!is_array($new_value)) {
                 $new_value = apply_filters('frm_get_default_value', $new_value, $field);
             }
             $new_value = str_replace('"', '"', $new_value);
             if ($is_default) {
                 $field->default_value = $new_value;
             } else {
                 $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field);
             }
             $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => maybe_unserialize($field->default_value), 'name' => stripslashes($field->name), 'description' => stripslashes($field->description), 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => stripslashes_deep(maybe_unserialize($field->options)), 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
             /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
                   foreach((array)$field_array['options'] as $opt_key => $opt){
                       if(!is_array($opt))
                           $field_array['options'][$opt_key] = array('label' => $opt);
                       unset($opt);
                       unset($opt_key);
                   }
               } */
             $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
             $opt_defaults['required_indicator'] = '';
             foreach ($opt_defaults as $opt => $default_opt) {
                 $field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
                 unset($opt);
                 unset($default_opt);
             }
             unset($opt_defaults);
             if ($field_array['size'] == '') {
                 $field_array['size'] = $frm_sidebar_width;
             }
             if ($field_array['custom_html'] == '') {
                 $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
             }
             $values['fields'][] = apply_filters('frm_setup_new_fields_vars', stripslashes_deep($field_array), $field);
             if (!$form or !isset($form->id)) {
                 $form = $frm_form->getOne($field->form_id);
             }
         }
         $form->options = maybe_unserialize($form->options);
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 $values[$opt] = FrmAppHelper::get_post_param($opt, $value);
             }
         }
         if (!isset($values['custom_style'])) {
             $values['custom_style'] = $frm_settings->load_style != 'none';
         }
         if (!isset($values['email_to'])) {
             $values['email_to'] = '';
         }
         if (!isset($values['submit_value'])) {
             $values['submit_value'] = $frm_settings->submit_value;
         }
         if (!isset($values['success_msg'])) {
             $values['success_msg'] = $frm_settings->success_msg;
         }
         if (!isset($values['akismet'])) {
             $values['akismet'] = '';
         }
         if (!isset($values['before_html'])) {
             $values['before_html'] = FrmFormsHelper::get_default_html('before');
         }
         if (!isset($values['after_html'])) {
             $values['after_html'] = FrmFormsHelper::get_default_html('after');
         }
     }
     return $values;
 }
开发者ID:edelkevis,项目名称:git-plus-wordpress,代码行数:86,代码来源:FrmEntriesHelper.php

示例7: setup_new_vars

 public static function setup_new_vars($fields, $form = '', $reset = false)
 {
     global $frm_settings, $frm_vars;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = FrmAppHelper::get_post_param($var, $default);
     }
     $values['fields'] = array();
     if (empty($fields)) {
         return apply_filters('frm_setup_new_entry', $values);
     }
     foreach ((array) $fields as $field) {
         $field->field_options = maybe_unserialize($field->field_options);
         $default = $field->default_value;
         $posted_val = false;
         if ($reset) {
             $new_value = $default;
         } else {
             if ($_POST && isset($_POST['item_meta'][$field->id]) && $_POST['item_meta'][$field->id] != '') {
                 $new_value = stripslashes_deep($_POST['item_meta'][$field->id]);
                 $posted_val = true;
             } else {
                 if (isset($field->field_options['clear_on_focus']) && $field->field_options['clear_on_focus']) {
                     $new_value = '';
                 } else {
                     $new_value = $default;
                 }
             }
         }
         $is_default = $new_value == $default ? true : false;
         //If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
         if ($field && ($field->type == 'data' && $field->field_options['data_type'] == 'checkbox' || $field->type == 'checkbox' || $field->type == 'select' && isset($field->field_options['multiple']) && $field->field_options['multiple'] == 1)) {
             $return_array = true;
         } else {
             $return_array = false;
         }
         $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
         if (!is_array($new_value)) {
             if ($is_default) {
                 $new_value = $field->default_value;
             } else {
                 if (!$posted_val) {
                     $new_value = apply_filters('frm_filter_default_value', $new_value, $field);
                 }
             }
             $new_value = str_replace('"', '"', $new_value);
         }
         unset($is_default);
         unset($posted_val);
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         $opt_defaults['required_indicator'] = '';
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
             unset($opt);
             unset($default_opt);
         }
         unset($opt_defaults);
         if ($field_array['size'] == '') {
             $field_array['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : '';
         }
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
         }
         $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
         foreach ((array) $field->field_options as $k => $v) {
             if (!isset($field_array[$k])) {
                 $field_array[$k] = $v;
             }
             unset($k);
             unset($v);
         }
         $values['fields'][] = $field_array;
         if (!$form or !isset($form->id)) {
             $frm_form = new FrmForm();
             $form = $frm_form->getOne($field->form_id);
         }
     }
     $form->options = maybe_unserialize($form->options);
     if (is_array($form->options)) {
         foreach ($form->options as $opt => $value) {
             $values[$opt] = FrmAppHelper::get_post_param($opt, $value);
         }
     }
     if (!isset($values['custom_style'])) {
         $values['custom_style'] = $frm_settings->load_style != 'none';
     }
     if (!isset($values['email_to'])) {
         $values['email_to'] = '';
     }
     if (!isset($values['submit_value'])) {
         $values['submit_value'] = $frm_settings->submit_value;
     }
     if (!isset($values['success_msg'])) {
         $values['success_msg'] = $frm_settings->success_msg;
     }
     if (!isset($values['akismet'])) {
         $values['akismet'] = '';
     }
     if (!isset($values['before_html'])) {
//.........这里部分代码省略.........
开发者ID:amit0773,项目名称:manaslake,代码行数:101,代码来源:FrmEntriesHelper.php

示例8: update_fields

 /**
  * @return array
  */
 public static function update_fields($id, $values)
 {
     if (!isset($values['options']) && !isset($values['item_meta']) && !isset($values['field_options'])) {
         return $values;
     }
     $all_fields = FrmField::get_all_for_form($id);
     if (empty($all_fields)) {
         return $values;
     }
     if (!isset($values['item_meta'])) {
         $values['item_meta'] = array();
     }
     $field_array = array();
     $existing_keys = array_keys($values['item_meta']);
     foreach ($all_fields as $fid) {
         if (!in_array($fid->id, $existing_keys) && (isset($values['frm_fields_submitted']) && in_array($fid->id, $values['frm_fields_submitted'])) || isset($values['options'])) {
             $values['item_meta'][$fid->id] = '';
         }
         $field_array[$fid->id] = $fid;
     }
     unset($all_fields);
     foreach ($values['item_meta'] as $field_id => $default_value) {
         if (isset($field_array[$field_id])) {
             $field = $field_array[$field_id];
         } else {
             $field = FrmField::getOne($field_id);
         }
         if (!$field) {
             continue;
         }
         $is_settings_page = isset($values['options']) || isset($values['field_options']['custom_html_' . $field_id]);
         if ($is_settings_page) {
             //updating the settings page
             if (isset($values['field_options']['custom_html_' . $field_id])) {
                 $field->field_options['custom_html'] = isset($values['field_options']['custom_html_' . $field_id]) ? $values['field_options']['custom_html_' . $field_id] : (isset($field->field_options['custom_html']) ? $field->field_options['custom_html'] : FrmFieldsHelper::get_default_html($field->type));
                 $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
                 FrmField::update($field_id, array('field_options' => $field->field_options));
             } else {
                 if ($field->type == 'hidden' || $field->type == 'user_id') {
                     $prev_opts = $field->field_options;
                     $field->field_options = apply_filters('frm_update_form_field_options', $field->field_options, $field, $values);
                     if ($prev_opts != $field->field_options) {
                         FrmField::update($field_id, array('field_options' => $field->field_options));
                     }
                     unset($prev_opts);
                 }
             }
         }
         if ($is_settings_page && !defined('WP_IMPORTING')) {
             continue;
         }
         //updating the form
         $update_options = FrmFieldsHelper::get_default_field_opts($field->type, $field, true);
         unset($update_options['custom_html']);
         // don't check for POST html
         $update_options = apply_filters('frm_field_options_to_update', $update_options);
         foreach ($update_options as $opt => $default) {
             $field->field_options[$opt] = isset($values['field_options'][$opt . '_' . $field_id]) ? trim(sanitize_text_field($values['field_options'][$opt . '_' . $field_id])) : $default;
         }
         $field->field_options = apply_filters('frm_update_field_options', $field->field_options, $field, $values);
         $default_value = maybe_serialize($values['item_meta'][$field_id]);
         $field_key = isset($values['field_options']['field_key_' . $field_id]) ? $values['field_options']['field_key_' . $field_id] : $field->field_key;
         $required = isset($values['field_options']['required_' . $field_id]) ? $values['field_options']['required_' . $field_id] : false;
         $field_type = isset($values['field_options']['type_' . $field_id]) ? $values['field_options']['type_' . $field_id] : $field->type;
         $field_description = isset($values['field_options']['description_' . $field_id]) ? $values['field_options']['description_' . $field_id] : $field->description;
         FrmField::update($field_id, array('field_key' => $field_key, 'type' => $field_type, 'default_value' => $default_value, 'field_options' => $field->field_options, 'description' => $field_description, 'required' => $required));
         FrmField::delete_form_transient($field->form_id);
     }
     self::clear_form_cache();
     return $values;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:74,代码来源:FrmForm.php

示例9: setup_edit_vars

 public static function setup_edit_vars($record, $table, $fields = '', $default = false, $post_values = array())
 {
     if (!$record) {
         return false;
     }
     global $frm_entry_meta, $frm_settings, $frm_vars;
     if (empty($post_values)) {
         $post_values = stripslashes_deep($_POST);
     }
     $values = array('id' => $record->id, 'fields' => array());
     foreach (array('name', 'description') as $var) {
         $default_val = isset($record->{$var}) ? $record->{$var} : '';
         $values[$var] = FrmAppHelper::get_param($var, $default_val);
         unset($var, $default_val);
     }
     if (apply_filters('frm_use_wpautop', true)) {
         $values['description'] = wpautop(str_replace('<br>', '<br />', $values['description']));
     }
     foreach ((array) $fields as $field) {
         if ($default) {
             $meta_value = $field->default_value;
         } else {
             if ($record->post_id and class_exists('FrmProEntryMetaHelper') and isset($field->field_options['post_field']) and $field->field_options['post_field']) {
                 if (!isset($field->field_options['custom_field'])) {
                     $field->field_options['custom_field'] = '';
                 }
                 $meta_value = FrmProEntryMetaHelper::get_post_value($record->post_id, $field->field_options['post_field'], $field->field_options['custom_field'], array('truncate' => false, 'type' => $field->type, 'form_id' => $field->form_id, 'field' => $field));
             } else {
                 if (isset($record->metas)) {
                     $meta_value = isset($record->metas[$field->id]) ? $record->metas[$field->id] : false;
                 } else {
                     $meta_value = $frm_entry_meta->get_entry_meta_by_field($record->id, $field->id);
                 }
             }
         }
         $field_type = isset($post_values['field_options']['type_' . $field->id]) ? $post_values['field_options']['type_' . $field->id] : $field->type;
         $new_value = isset($post_values['item_meta'][$field->id]) ? maybe_unserialize($post_values['item_meta'][$field->id]) : $meta_value;
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field_type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
         /*if(in_array($field_array['type'], array('checkbox', 'radio', 'select')) and !empty($field_array['options'])){
               foreach((array)$field_array['options'] as $opt_key => $opt){
                   if(!is_array($opt))
                       $field_array['options'][$opt_key] = array('label' => $opt);
                   unset($opt);
                   unset($opt_key);
               }
           }*/
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = $post_values && isset($post_values['field_options'][$opt . '_' . $field->id]) ? maybe_unserialize($post_values['field_options'][$opt . '_' . $field->id]) : (isset($field->field_options[$opt]) ? $field->field_options[$opt] : $default_opt);
             if ($opt == 'blank' and $field_array[$opt] == '') {
                 $field_array[$opt] = $frm_settings->blank_msg;
             } else {
                 if ($opt == 'invalid' and $field_array[$opt] == '') {
                     if ($field_type == 'captcha') {
                         $field_array[$opt] = $frm_settings->re_msg;
                     } else {
                         $field_array[$opt] = sprintf(__('%s is invalid', 'formidable'), $field_array['name']);
                     }
                 }
             }
         }
         unset($opt_defaults);
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field_type);
         }
         if ($field_array['size'] == '') {
             $field_array['size'] = isset($frm_vars['sidebar_width']) ? $frm_vars['sidebar_width'] : '';
         }
         $field_array = apply_filters('frm_setup_edit_fields_vars', $field_array, $field, $values['id']);
         if (!isset($field_array['unique']) or !$field_array['unique']) {
             $field_array['unique_msg'] = '';
         }
         foreach ((array) $field->field_options as $k => $v) {
             if (!isset($field_array[$k])) {
                 $field_array[$k] = $v;
             }
             unset($k);
             unset($v);
         }
         $values['fields'][$field->id] = $field_array;
         unset($field);
     }
     $frm_form = new FrmForm();
     $form = $frm_form->getOne($table == 'entries' ? $record->form_id : $record->id);
     unset($frm_form);
     if ($form) {
         $values['form_name'] = isset($record->form_id) ? $form->name : '';
         if (is_array($form->options)) {
             foreach ($form->options as $opt => $value) {
                 if (in_array($opt, array('email_to', 'reply_to', 'reply_to_name'))) {
                     $values['notification'][0][$opt] = isset($post_values["notification[0][{$opt}]"]) ? maybe_unserialize($post_values["notification[0][{$opt}]"]) : $value;
                 }
                 $values[$opt] = isset($post_values[$opt]) ? maybe_unserialize($post_values[$opt]) : $value;
             }
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     //set to posted value or default
     foreach ($form_defaults as $opt => $default) {
         if (!isset($values[$opt]) or $values[$opt] == '') {
//.........这里部分代码省略.........
开发者ID:amit0773,项目名称:manaslake,代码行数:101,代码来源:FrmAppHelper.php

示例10: setup_new_vars

 public static function setup_new_vars($fields, $form = '', $reset = false)
 {
     global $frm_vars;
     $values = array();
     foreach (array('name' => '', 'description' => '', 'item_key' => '') as $var => $default) {
         $values[$var] = FrmAppHelper::get_post_param($var, $default);
     }
     $values['fields'] = array();
     if (empty($fields)) {
         return apply_filters('frm_setup_new_entry', $values);
     }
     foreach ((array) $fields as $field) {
         $default = $field->default_value;
         $posted_val = false;
         $new_value = $default;
         if (!$reset && $_POST && isset($_POST['item_meta'][$field->id]) && $_POST['item_meta'][$field->id] != '') {
             $new_value = stripslashes_deep($_POST['item_meta'][$field->id]);
             $posted_val = true;
         } else {
             if (FrmField::is_option_true($field, 'clear_on_focus')) {
                 $new_value = '';
             }
         }
         $is_default = $new_value == $default ? true : false;
         //If checkbox, multi-select dropdown, or checkbox data from entries field, set return array to true
         $return_array = FrmField::is_field_with_multiple_values($field);
         $field->default_value = apply_filters('frm_get_default_value', $field->default_value, $field, true, $return_array);
         if (!is_array($new_value)) {
             if ($is_default) {
                 $new_value = $field->default_value;
             } else {
                 if (!$posted_val) {
                     $new_value = apply_filters('frm_filter_default_value', $new_value, $field);
                 }
             }
             $new_value = str_replace('"', '&quot;', $new_value);
         }
         unset($is_default, $posted_val);
         $field_array = array('id' => $field->id, 'value' => $new_value, 'default_value' => $field->default_value, 'name' => $field->name, 'description' => $field->description, 'type' => apply_filters('frm_field_type', $field->type, $field, $new_value), 'options' => $field->options, 'required' => $field->required, 'field_key' => $field->field_key, 'field_order' => $field->field_order, 'form_id' => $field->form_id);
         $opt_defaults = FrmFieldsHelper::get_default_field_opts($field_array['type'], $field, true);
         $opt_defaults['required_indicator'] = '';
         $opt_defaults['original_type'] = $field->type;
         foreach ($opt_defaults as $opt => $default_opt) {
             $field_array[$opt] = isset($field->field_options[$opt]) && $field->field_options[$opt] != '' ? $field->field_options[$opt] : $default_opt;
             unset($opt, $default_opt);
         }
         unset($opt_defaults);
         if ($field_array['custom_html'] == '') {
             $field_array['custom_html'] = FrmFieldsHelper::get_default_html($field->type);
         }
         $field_array = apply_filters('frm_setup_new_fields_vars', $field_array, $field);
         $field_array = array_merge($field->field_options, $field_array);
         $values['fields'][] = $field_array;
         if (!$form || !isset($form->id)) {
             $form = FrmForm::getOne($field->form_id);
         }
     }
     $form->options = maybe_unserialize($form->options);
     if (is_array($form->options)) {
         foreach ($form->options as $opt => $value) {
             $values[$opt] = FrmAppHelper::get_post_param($opt, $value);
             unset($opt, $value);
         }
     }
     $form_defaults = FrmFormsHelper::get_default_opts();
     $frm_settings = FrmAppHelper::get_settings();
     $form_defaults['custom_style'] = $frm_settings->load_style != 'none';
     $values = array_merge($form_defaults, $values);
     return apply_filters('frm_setup_new_entry', $values);
 }
开发者ID:EliasGoldberg,项目名称:troop-sim,代码行数:70,代码来源:FrmEntriesHelper.php


注:本文中的FrmFieldsHelper::get_default_field_opts方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。