本文整理汇总了PHP中FrmForm::update方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmForm::update方法的具体用法?PHP FrmForm::update怎么用?PHP FrmForm::update使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmForm
的用法示例。
在下文中一共展示了FrmForm::update方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: update_child_form_parents
/**
* Update parent_form_id for child forms that were imported before parents
*
* @since 2.0.13
*
* @param array $child_forms_missing_parent
* @param array $imported_forms
*/
private static function update_child_form_parents($child_forms_missing_parent, $imported_forms)
{
foreach ($child_forms_missing_parent as $old_parent_form_id => $child_form_ids) {
if (isset($imported_forms[$old_parent_form_id])) {
// Update all children with this old parent_form_id
$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
foreach ($child_form_ids as $child_form_id) {
FrmForm::update($child_form_id, array('parent_form_id' => $new_parent_form_id));
}
}
}
}
示例2: 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);
}
//.........这里部分代码省略.........
示例3: update_object
function update_object($form_id, $fields)
{
return FrmForm::update($form_id, $fields);
}
示例4: update
public static function update($values = false)
{
$frm_form = new FrmForm();
if (!$values) {
$values = $_POST;
}
$errors = $frm_form->validate($values);
if (!current_user_can('frm_edit_forms') || $_POST && (!isset($values['frm_save_form']) || !wp_verify_nonce($values['frm_save_form'], 'frm_save_form_nonce'))) {
global $frm_settings;
$errors['form'] = $frm_settings->admin_permission;
}
$id = isset($values['id']) ? (int) $values['id'] : (int) FrmAppHelper::get_param('id');
if (count($errors) > 0) {
return self::get_edit_vars($id, $errors);
} else {
$record = $frm_form->update($id, $values);
$message = __('Form was Successfully Updated', 'formidable');
if (defined('DOING_AJAX')) {
die($message);
}
return self::get_edit_vars($id, '', $message);
}
}
示例5: maybe_update_child_form_parent_id
/**
* Update the parent_form_id on imported child forms
* Child forms are imported first so their parent_form_id will need to be updated after the parent is imported
*
* @since 2.0.6
* @param array $imported_forms
* @param array $child_forms
*/
private static function maybe_update_child_form_parent_id($imported_forms, $child_forms)
{
foreach ($child_forms as $child_form_id => $old_parent_form_id) {
if (isset($imported_forms[$old_parent_form_id]) && $imported_forms[$old_parent_form_id] != $old_parent_form_id) {
// Update all children with this old parent_form_id
$new_parent_form_id = (int) $imported_forms[$old_parent_form_id];
FrmForm::update($child_form_id, array('parent_form_id' => $new_parent_form_id));
}
}
}
示例6: 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;
}
示例7: update
public static function update($values = array())
{
if (empty($values)) {
$values = $_POST;
}
//Set radio button and checkbox meta equal to "other" value
if (FrmAppHelper::pro_is_installed()) {
$values = FrmProEntry::mod_other_vals($values, 'back');
}
$errors = FrmForm::validate($values);
$permission_error = FrmAppHelper::permission_nonce_error('frm_edit_forms', 'frm_save_form', 'frm_save_form_nonce');
if ($permission_error !== false) {
$errors['form'] = $permission_error;
}
$id = isset($values['id']) ? absint($values['id']) : FrmAppHelper::get_param('id', '', 'get', 'absint');
if (count($errors) > 0) {
return self::get_edit_vars($id, $errors);
} else {
FrmForm::update($id, $values);
$message = __('Form was Successfully Updated', 'formidable');
if (defined('DOING_AJAX')) {
wp_die($message);
}
return self::get_edit_vars($id, array(), $message);
}
}
示例8: update_custom_style_setting_after_import
/**
* After styles are imported, check for any forms that were linked
* and link them back up.
*
* @since 2.2.7
*/
private static function update_custom_style_setting_after_import($form_id)
{
$form = FrmForm::getOne($form_id);
if ($form && isset($form->options['old_style'])) {
$form = (array) $form;
$saved_style = $form['options']['custom_style'];
$form['options']['custom_style'] = $form['options']['old_style'];
self::update_custom_style_setting_on_import($form);
$has_changed = $form['options']['custom_style'] != $saved_style && $form['options']['custom_style'] != $form['options']['old_style'];
if ($has_changed) {
FrmForm::update($form['id'], $form);
}
}
}
示例9: migrate_to_29
/**
* Switch repeating section forms to published and give them names
*/
private static function migrate_to_29()
{
// Get all section fields
$dividers = FrmField::getAll(array('fi.type' => 'divider'));
// Update the form name and status for repeating sections
foreach ($dividers as $d) {
if (!FrmField::is_repeating_field($d)) {
continue;
}
$form_id = $d->field_options['form_select'];
$new_name = $d->name;
if ($form_id && is_numeric($form_id)) {
FrmForm::update($form_id, array('name' => $new_name, 'status' => 'published'));
}
}
}
示例10: update_repeating_form_name
/**
*
* Update the repeating form name when a repeating section name is updated
*
* @since 2.0.12
*
* @param array $atts
*/
public static function update_repeating_form_name($atts)
{
$field = FrmField::getOne($atts['id']);
if (FrmField::is_repeating_field($field)) {
// Update the repeating form name
FrmForm::update($field->field_options['form_select'], array('name' => $atts['value']));
}
}