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


PHP FrmForm::create方法代码示例

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


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

示例1: test_create

 /**
  * @covers FrmForm::create
  */
 function test_create()
 {
     $values = FrmFormsHelper::setup_new_vars(false);
     $form_id = FrmForm::create($values);
     $this->assertTrue(is_numeric($form_id));
     $this->assertNotEmpty($form_id);
 }
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:10,代码来源:test_FrmForm.php

示例2: duplicate

 public static function duplicate($old_form_id, $form_id, $copy_keys = false, $blog_id = false)
 {
     global $frm_duplicate_ids;
     $fields = self::getAll(array('fi.form_id' => $old_form_id), 'field_order', '', $blog_id);
     foreach ((array) $fields as $field) {
         $new_key = $copy_keys ? $field->field_key : '';
         if ($copy_keys && substr($field->field_key, -1) == 2) {
             $new_key = rtrim($new_key, 2);
         }
         $values = array();
         FrmFieldsHelper::fill_field($values, $field, $form_id, $new_key);
         // If this is a repeating section, create new form
         if ($field->type == 'divider' && self::is_option_true($field, 'repeat')) {
             // create the repeatable form
             $repeat_form_values = FrmFormsHelper::setup_new_vars(array('parent_form_id' => $form_id));
             $new_repeat_form_id = FrmForm::create($repeat_form_values);
             // Save old form_select
             $old_repeat_form_id = $field->field_options['form_select'];
             // Update form_select for repeating field
             $values['field_options']['form_select'] = $new_repeat_form_id;
         }
         // If this is a field inside of a repeating section, associate it with the correct form
         if ($field->form_id != $old_form_id && isset($old_repeat_form_id) && isset($new_repeat_form_id) && $field->form_id == $old_repeat_form_id) {
             $values['form_id'] = $new_repeat_form_id;
         }
         $values = apply_filters('frm_duplicated_field', $values);
         $new_id = self::create($values);
         $frm_duplicate_ids[$field->id] = $new_id;
         $frm_duplicate_ids[$field->field_key] = $new_id;
         unset($field);
     }
 }
开发者ID:realnerdo,项目名称:multiempac,代码行数:32,代码来源:FrmField.php

示例3: FrmForm

 function test_create_form()
 {
     FrmAppController::install();
     $frm_form = new FrmForm();
     $values = FrmFormsHelper::setup_new_vars(false);
     $id = $frm_form->create($values);
     $this->assertGreaterThan(0, $id);
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:8,代码来源:test_wordpress_plugin_tests.php

示例4: new_form

 public static function new_form($values = array())
 {
     FrmAppHelper::permission_check('frm_edit_forms');
     global $frm_vars;
     $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
     $action = empty($values) ? FrmAppHelper::get_param($action, '', 'get', 'sanitize_title') : $values[$action];
     if ($action == 'create') {
         return self::create($values);
     } else {
         if ($action == 'new') {
             $frm_field_selection = FrmField::field_selection();
             $values = FrmFormsHelper::setup_new_vars($values);
             $id = FrmForm::create($values);
             $form = FrmForm::getOne($id);
             // add default email notification
             $action_control = FrmFormActionsController::get_form_actions('email');
             $action_control->create($form->id);
             $all_templates = FrmForm::getAll(array('is_template' => 1), 'name');
             $values['id'] = $id;
             require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php';
         }
     }
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:23,代码来源:FrmFormsController.php

示例5: import_xml_forms

 public static function import_xml_forms($forms, $imported)
 {
     // Keep track of repeating sections and child forms that are imported
     $repeat_fields = $child_forms_missing_parent = array();
     foreach ($forms as $item) {
         $form = array('id' => (int) $item->id, 'form_key' => (string) $item->form_key, 'name' => (string) $item->name, 'description' => (string) $item->description, 'options' => (string) $item->options, 'logged_in' => (int) $item->logged_in, 'is_template' => (int) $item->is_template, 'default_template' => (int) $item->default_template, 'editable' => (int) $item->editable, 'status' => (string) $item->status, 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)));
         $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
         // if template, allow to edit if form keys match, otherwise, creation date must also match
         $edit_query = array('form_key' => $form['form_key'], 'is_template' => $form['is_template']);
         if (!$form['is_template']) {
             $edit_query['created_at'] = $form['created_at'];
         }
         $old_parent_form_id = self::maybe_replace_parent_form_id($imported['forms'], $form['parent_form_id']);
         $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
         $this_form = FrmForm::getAll($edit_query, '', 1);
         unset($edit_query);
         if (!empty($this_form)) {
             $old_id = $form_id = $this_form->id;
             FrmForm::update($form_id, $form);
             $imported['updated']['forms']++;
             // Keep track of whether this specific form was updated or not
             $imported['form_status'][$form_id] = 'updated';
             $form_fields = FrmField::get_all_for_form($form_id);
             $old_fields = array();
             foreach ($form_fields as $f) {
                 $old_fields[$f->id] = $f;
                 $old_fields[$f->field_key] = $f->id;
                 unset($f);
             }
             $form_fields = $old_fields;
             unset($old_fields);
         } else {
             $old_id = false;
             //form does not exist, so create it
             $form_id = FrmForm::create($form);
             if ($form_id) {
                 $imported['imported']['forms']++;
                 // Keep track of whether this specific form was updated or not
                 $imported['form_status'][$form_id] = 'imported';
                 self::track_child_forms_missing_parent((int) $form_id, $old_parent_form_id, $child_forms_missing_parent);
             }
         }
         self::import_xml_fields($item->field, $form_id, $this_form, $form_fields, $imported, $repeat_fields);
         // Delete any fields attached to this form that were not included in the template
         if (isset($form_fields) && !empty($form_fields)) {
             foreach ($form_fields as $field) {
                 if (is_object($field)) {
                     FrmField::destroy($field->id);
                 }
                 unset($field);
             }
             unset($form_fields);
         }
         // Update field ids/keys to new ones
         do_action('frm_after_duplicate_form', $form_id, $form, array('old_id' => $old_id));
         $imported['forms'][(int) $item->id] = $form_id;
         // Send pre 2.0 form options through function that creates actions
         self::migrate_form_settings_to_actions($form['options'], $form_id, $imported, $switch = true);
         unset($form, $item);
     }
     self::update_repeat_field_options($repeat_fields, $imported['forms']);
     self::update_child_form_parents($child_forms_missing_parent, $imported['forms']);
     return $imported;
 }
开发者ID:EyesX,项目名称:formidable-forms,代码行数:64,代码来源:FrmXMLHelper.php

示例6: create_object

 function create_object($args)
 {
     return FrmForm::create($args);
 }
开发者ID:knightzac19,项目名称:formidable-forms,代码行数:4,代码来源:frm_factory.php

示例7: import_xml_forms

 public static function import_xml_forms($forms, $imported)
 {
     // Keep track of repeating sections that are created
     $repeat_fields = array();
     foreach ($forms as $item) {
         $form = array('id' => (int) $item->id, 'form_key' => (string) $item->form_key, 'name' => (string) $item->name, 'description' => (string) $item->description, 'options' => (string) $item->options, 'logged_in' => (int) $item->logged_in, 'is_template' => (int) $item->is_template, 'default_template' => (int) $item->default_template, 'editable' => (int) $item->editable, 'status' => (string) $item->status, 'parent_form_id' => isset($item->parent_form_id) ? (int) $item->parent_form_id : 0, 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)));
         $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
         // if template, allow to edit if form keys match, otherwise, creation date must also match
         $edit_query = array('form_key' => $form['form_key'], 'is_template' => $form['is_template']);
         if (!$form['is_template']) {
             $edit_query['created_at'] = $form['created_at'];
         }
         if (!empty($form['parent_form_id']) && isset($imported['forms'][$form['parent_form_id']])) {
             // replace the old parent id with the new one
             $form['parent_form_id'] = $imported['forms'][$form['parent_form_id']];
         }
         $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
         $this_form = FrmForm::getAll($edit_query, '', 1);
         unset($edit_query);
         if (!empty($this_form)) {
             $old_id = $form_id = $this_form->id;
             FrmForm::update($form_id, $form);
             $imported['updated']['forms']++;
             // Keep track of whether this specific form was updated or not
             $imported['form_status'][$form_id] = 'updated';
             $form_fields = FrmField::get_all_for_form($form_id);
             $old_fields = array();
             foreach ($form_fields as $f) {
                 $old_fields[$f->id] = $f;
                 $old_fields[$f->field_key] = $f->id;
                 unset($f);
             }
             $form_fields = $old_fields;
             unset($old_fields);
         } else {
             $old_id = false;
             //form does not exist, so create it
             $form_id = FrmForm::create($form);
             if ($form_id) {
                 $imported['imported']['forms']++;
                 // Keep track of whether this specific form was updated or not
                 $imported['form_status'][$form_id] = 'imported';
             }
         }
         foreach ($item->field as $field) {
             $f = array('id' => (int) $field->id, 'field_key' => (string) $field->field_key, 'name' => (string) $field->name, 'description' => (string) $field->description, 'type' => (string) $field->type, 'default_value' => FrmAppHelper::maybe_json_decode((string) $field->default_value), 'field_order' => (int) $field->field_order, 'form_id' => (int) $form_id, 'required' => (int) $field->required, 'options' => FrmAppHelper::maybe_json_decode((string) $field->options), 'field_options' => FrmAppHelper::maybe_json_decode((string) $field->field_options));
             if (is_array($f['default_value']) && in_array($f['type'], array('text', 'email', 'url', 'textarea', 'number', 'phone', 'date', 'time', 'hidden', 'password', 'tag', 'image'))) {
                 if (count($f['default_value']) === 1) {
                     $f['default_value'] = '[' . reset($f['default_value']) . ']';
                 } else {
                     $f['default_value'] = reset($f['default_value']);
                 }
             }
             $f = apply_filters('frm_duplicated_field', $f);
             if (!empty($this_form)) {
                 // check for field to edit by field id
                 if (isset($form_fields[$f['id']])) {
                     FrmField::update($f['id'], $f);
                     $imported['updated']['fields']++;
                     unset($form_fields[$f['id']]);
                     //unset old field key
                     if (isset($form_fields[$f['field_key']])) {
                         unset($form_fields[$f['field_key']]);
                     }
                 } else {
                     if (isset($form_fields[$f['field_key']])) {
                         // check for field to edit by field key
                         unset($f['id']);
                         FrmField::update($form_fields[$f['field_key']], $f);
                         $imported['updated']['fields']++;
                         unset($form_fields[$form_fields[$f['field_key']]]);
                         //unset old field id
                         unset($form_fields[$f['field_key']]);
                         //unset old field key
                     } else {
                         $new_id = FrmField::create($f);
                         if ($new_id == false) {
                             continue;
                         }
                         self::track_repeating_fields($f, $new_id, $repeat_fields);
                         // if no matching field id or key in this form, create the field
                         $imported['imported']['fields']++;
                     }
                 }
             } else {
                 $new_id = FrmField::create($f);
                 if ($new_id == false) {
                     continue;
                 }
                 self::track_repeating_fields($f, $new_id, $repeat_fields);
                 $imported['imported']['fields']++;
             }
             unset($field, $new_id);
         }
         // Delete any fields attached to this form that were not included in the template
         if (isset($form_fields) && !empty($form_fields)) {
             foreach ($form_fields as $field) {
                 if (is_object($field)) {
                     FrmField::destroy($field->id);
                 }
//.........这里部分代码省略.........
开发者ID:rbkhrlstn,项目名称:formidable-forms,代码行数:101,代码来源:FrmXMLHelper.php

示例8: new_form

 public static function new_form($values = false)
 {
     global $frm_vars;
     $action = isset($_REQUEST['frm_action']) ? 'frm_action' : 'action';
     $action = $values ? $values[$action] : FrmAppHelper::get_param($action);
     $frm_form = new FrmForm();
     if ($action == 'create') {
         return self::create($values);
     } else {
         if ($action == 'new') {
             $frm_field_selection = FrmFieldsHelper::field_selection();
             $values = FrmFormsHelper::setup_new_vars($values);
             $id = $frm_form->create($values);
             $form = $frm_form->getOne($id);
             $values['id'] = $id;
             require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new.php';
         } else {
             $all_templates = $frm_form->getAll(array('is_template' => 1), 'name');
             require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/new-selection.php';
         }
     }
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:22,代码来源:FrmFormsController.php

示例9: import_xml_forms

 public static function import_xml_forms($forms, $imported)
 {
     $frm_form = new FrmForm();
     $frm_field = new FrmField();
     foreach ($forms as $item) {
         $form = array('id' => (int) $item->id, 'form_key' => (string) $item->form_key, 'name' => (string) $item->name, 'description' => (string) $item->description, 'options' => (string) $item->options, 'logged_in' => (int) $item->logged_in, 'is_template' => (int) $item->is_template, 'default_template' => (int) $item->default_template, 'editable' => (int) $item->editable, 'status' => (string) $item->status, 'created_at' => date('Y-m-d H:i:s', strtotime((string) $item->created_at)));
         $form['options'] = FrmAppHelper::maybe_json_decode($form['options']);
         // if template, allow to edit if form keys match, otherwise, creation date must also match
         $edit_query = array('form_key' => $form['form_key'], 'is_template' => $form['is_template']);
         if (!$form['is_template']) {
             $edit_query['created_at'] = $form['created_at'];
         }
         $edit_query = apply_filters('frm_match_xml_form', $edit_query, $form);
         $this_form = $frm_form->getAll($edit_query, '', 1);
         unset($edit_query);
         if (!empty($this_form)) {
             $form_id = $this_form->id;
             $frm_form->update($form_id, $form);
             $imported['updated']['forms']++;
             $form_fields = $frm_field->getAll(array('fi.form_id' => $form_id), 'field_order');
             $old_fields = array();
             foreach ($form_fields as $f) {
                 $old_fields[$f->id] = $f;
                 $old_fields[$f->field_key] = $f->id;
                 unset($f);
             }
             $form_fields = $old_fields;
             unset($old_fields);
         } else {
             //form does not exist, so create it
             if ($form_id = $frm_form->create($form)) {
                 $imported['imported']['forms']++;
             }
         }
         foreach ($item->field as $field) {
             $f = array('id' => (int) $field->id, 'field_key' => (string) $field->field_key, 'name' => (string) $field->name, 'description' => (string) $field->description, 'type' => (string) $field->type, 'default_value' => FrmAppHelper::maybe_json_decode((string) $field->default_value), 'field_order' => (int) $field->field_order, 'form_id' => (int) $form_id, 'required' => (int) $field->required, 'options' => FrmAppHelper::maybe_json_decode((string) $field->options), 'field_options' => FrmAppHelper::maybe_json_decode((string) $field->field_options));
             if (is_array($f['default_value']) && in_array($f['type'], array('text', 'email', 'url', 'textarea', 'number', 'phone', 'date', 'time', 'image', 'hidden', 'password', 'tag'))) {
                 if (count($f['default_value']) === 1) {
                     $f['default_value'] = '[' . reset($f['default_value']) . ']';
                 } else {
                     $f['default_value'] = reset($f['default_value']);
                 }
             }
             $f = apply_filters('frm_duplicated_field', $f);
             if ($this_form) {
                 // check for field to edit by field id
                 if (isset($form_fields[$f['id']])) {
                     $frm_field->update($f['id'], $f);
                     $imported['updated']['fields']++;
                     unset($form_fields[$f['id']]);
                     //unset old field key
                     if (isset($form_fields[$f['field_key']])) {
                         unset($form_fields[$f['field_key']]);
                     }
                 } else {
                     if (isset($form_fields[$f['field_key']])) {
                         // check for field to edit by field key
                         unset($f['id']);
                         $frm_field->update($form_fields[$f['field_key']], $f);
                         $imported['updated']['fields']++;
                         unset($form_fields[$form_fields[$f['field_key']]]);
                         //unset old field id
                         unset($form_fields[$f['field_key']]);
                         //unset old field key
                     } else {
                         if ($frm_field->create($f)) {
                             // if no matching field id or key in this form, create the field
                             $imported['imported']['fields']++;
                         }
                     }
                 }
             } else {
                 if ($frm_field->create($f)) {
                     $imported['imported']['fields']++;
                 }
             }
             unset($field);
         }
         // Delete any fields attached to this form that were not included in the template
         if (isset($form_fields) && !empty($form_fields)) {
             foreach ($form_fields as $field) {
                 if (is_object($field)) {
                     $frm_field->destroy($field->id);
                 }
                 unset($field);
             }
             unset($form_fields);
         }
         // Update field ids/keys to new ones
         do_action('frm_after_duplicate_form', $form_id, $form);
         $imported['forms'][(int) $item->id] = $form_id;
         unset($form);
         unset($item);
     }
     unset($frm_form);
     unset($frm_field);
     return $imported;
 }
开发者ID:amit0773,项目名称:manaslake,代码行数:98,代码来源:FrmXMLHelper.php

示例10: import_xml_forms

 public static function import_xml_forms($forms, $imported)
 {
     $child_forms = array();
     // Import child forms first
     self::put_child_forms_first($forms);
     foreach ($forms as $item) {
         $form = self::fill_form($item);
         self::update_custom_style_setting_on_import($form);
         $this_form = self::maybe_get_form($form);
         $old_id = $form_fields = false;
         if (!empty($this_form)) {
             $form_id = $old_id = $this_form->id;
             self::update_form($this_form, $form, $imported);
             $form_fields = self::get_form_fields($form_id);
         } else {
             $form_id = FrmForm::create($form);
             if ($form_id) {
                 $imported['imported']['forms']++;
                 // Keep track of whether this specific form was updated or not
                 $imported['form_status'][$form_id] = 'imported';
                 self::track_imported_child_forms((int) $form_id, $form['parent_form_id'], $child_forms);
             }
         }
         self::import_xml_fields($item->field, $form_id, $this_form, $form_fields, $imported);
         self::delete_removed_fields($form_fields);
         // Update field ids/keys to new ones
         do_action('frm_after_duplicate_form', $form_id, $form, array('old_id' => $old_id));
         $imported['forms'][(int) $item->id] = $form_id;
         // Send pre 2.0 form options through function that creates actions
         self::migrate_form_settings_to_actions($form['options'], $form_id, $imported, $switch = true);
         do_action('frm_after_import_form', $form_id, $form);
         unset($form, $item);
     }
     self::maybe_update_child_form_parent_id($imported['forms'], $child_forms);
     return $imported;
 }
开发者ID:uwmadisoncals,项目名称:Cluster-Plugins,代码行数:36,代码来源:FrmXMLHelper.php

示例11: create_repeat_form

 /**
  * Create the form for a repeating section
  *
  * @since 2.0.12
  *
  * @param int $form_id
  * @param array $atts
  * @return int $form_id
  */
 public static function create_repeat_form($form_id, $atts)
 {
     $form_values = array('parent_form_id' => $atts['parent_form_id'], 'name' => $atts['field_name'], 'status' => 'published');
     $form_values = FrmFormsHelper::setup_new_vars($form_values);
     $form_id = (int) FrmForm::create($form_values);
     return $form_id;
 }
开发者ID:swc-dng,项目名称:swcsandbox,代码行数:16,代码来源:FrmProField.php


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