/** * @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); }
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); } }
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); }
function __construct($factory = null) { parent::__construct($factory); global $wpdb; $this->default_generation_definitions = FrmFormsHelper::setup_new_vars(false); }
public static function add_default_templates($path, $default = true, $template = true) { _deprecated_function(__FUNCTION__, '1.07.05', 'FrmXMLController::add_default_templates()'); global $frm_field; $path = untrailingslashit(trim($path)); $templates = glob($path . "/*.php"); $frm_form = new FrmForm(); for ($i = count($templates) - 1; $i >= 0; $i--) { $filename = str_replace('.php', '', str_replace($path . '/', '', $templates[$i])); $template_query = array('form_key' => $filename); if ($template) { $template_query['is_template'] = 1; } if ($default) { $template_query['default_template'] = 1; } $form = $frm_form->getAll($template_query, '', 1); $values = FrmFormsHelper::setup_new_vars(); $values['form_key'] = $filename; $values['is_template'] = $template; $values['status'] = 'published'; if ($default) { $values['default_template'] = 1; } include $templates[$i]; //get updated form if (isset($form) && $form) { $form = $frm_form->getOne($form->id); } else { $form = $frm_form->getAll($template_query, '', 1); } if ($form) { do_action('frm_after_duplicate_form', $form->id, (array) $form); } } }
function add_default_templates($path, $default = true, $template = true) { global $frm_form, $frm_field; $templates = glob($path . "/*.php"); for ($i = count($templates) - 1; $i >= 0; $i--) { $filename = str_replace('.php', '', str_replace($path . '/', '', $templates[$i])); $template_query = array('form_key' => $filename); if ($template) { $template_query['is_template'] = 1; } if ($default) { $template_query['default_template'] = 1; } $form = $frm_form->getAll($template_query, '', 1); $values = FrmFormsHelper::setup_new_vars(); $values['form_key'] = $filename; $values['is_template'] = $template; $values['status'] = 'published'; if ($default) { $values['default_template'] = 1; } include_once $templates[$i]; } }
/** * 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; }