本文整理汇总了PHP中FrmFieldsHelper::setup_new_vars方法的典型用法代码示例。如果您正苦于以下问题:PHP FrmFieldsHelper::setup_new_vars方法的具体用法?PHP FrmFieldsHelper::setup_new_vars怎么用?PHP FrmFieldsHelper::setup_new_vars使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FrmFieldsHelper
的用法示例。
在下文中一共展示了FrmFieldsHelper::setup_new_vars方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: include_new_field
/**
* @param integer $form_id
*/
public static function include_new_field($field_type, $form_id)
{
$values = array();
if (FrmAppHelper::pro_is_installed()) {
$values['post_type'] = FrmProFormsHelper::post_type($form_id);
}
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_type, $form_id));
$field_id = FrmField::create($field_values);
if (!$field_id) {
return false;
}
$field = self::include_single_field($field_id, $values, $form_id);
return $field;
}
示例2: create
public static function create()
{
$field_data = $_POST['field'];
$form_id = $_POST['form_id'];
$values = array();
if (class_exists('FrmProForm')) {
$values['post_type'] = FrmProFormsHelper::post_type($form_id);
}
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
$frm_field = new FrmField();
$field_id = $frm_field->create($field_values);
if ($field_id) {
$field = FrmFieldsHelper::setup_edit_vars($frm_field->getOne($field_id));
$field_name = "item_meta[{$field_id}]";
$id = $form_id;
require FrmAppHelper::plugin_path() . '/classes/views/frm-forms/add_field.php';
}
die;
}
示例3: create
function create()
{
global $frm_field, $frm_ajax_url;
$field_data = $_POST['field'];
$form_id = $_POST['form_id'];
$values = array();
if (class_exists('FrmProForm')) {
$values['post_type'] = FrmProForm::post_type($form_id);
}
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars($field_data, $form_id));
$field_id = $frm_field->create($field_values);
if ($field_id) {
$field = FrmFieldsHelper::setup_edit_vars($frm_field->getOne($field_id));
$field_name = "item_meta[{$field_id}]";
$id = $form_id;
require FRM_VIEWS_PATH . '/frm-forms/add_field.php';
require FRM_VIEWS_PATH . '/frm-forms/new-field-js.php';
}
die;
}
示例4: create_object
function create_object($args)
{
$field_values = FrmFieldsHelper::setup_new_vars($args['type'], $args['form_id']);
return FrmField::create($field_values);
}
示例5: serialize
$field_values['options'] = serialize(array('', 'AL', 'AK', 'AS', 'AZ', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY'));
$field_values['field_options']['classes'] = 'frm_fourth';
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('text', $form_id));
$field_values['name'] = 'Postal Code';
$field_values['field_order'] = '10';
$field_values['field_options']['classes'] = 'frm_right_fourth';
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('select', $form_id));
$field_values['name'] = 'Country';
$field_values['required'] = 1;
$field_values['field_order'] = '11';
$field_values['field_options']['size'] = 1;
$field_values['options'] = serialize(array('', 'Afghanistan', 'Albania', 'Algeria', 'American Samoa', 'Andorra', 'Angola', 'Anguilla', 'Antarctica', 'Antigua and Barbuda', 'Argentina', 'Armenia', 'Aruba', 'Australia', 'Austria', 'Azerbaijan', 'Bahamas', 'Bahrain', 'Bangladesh', 'Barbados', 'Belarus', 'Belgium', 'Belize', 'Benin', 'Bermuda', 'Bhutan', 'Bolivia', 'Bosnia and Herzegovina', 'Botswana', 'Bouvet Island', 'Brazil', 'British Indian Ocean Territory', 'Brunei', 'Bulgaria', 'Burkina Faso', 'Burundi', 'Cambodia', 'Cameroon', 'Canada', 'Cape Verde', 'Cayman Islands', 'Central African Republic', 'Chad', 'Chile', 'China', 'Christmas Island', 'Cocos (Keeling) Islands', 'Colombia', 'Comoros', 'Congo', 'Cook Islands', 'Costa Rica', 'Côte d\'Ivoire', 'Croatia (Hrvatska)', 'Cuba', 'Cyprus', 'Czech Republic', 'Congo (DRC)', 'Denmark', 'Djibouti', 'Dominica', 'Dominican Republic', 'East Timor', 'Ecuador', 'Egypt', 'El Salvador', 'Equatorial Guinea', 'Eritrea', 'Estonia', 'Ethiopia', 'Falkland Islands (Islas Malvinas)', 'Faroe Islands', 'Fiji Islands', 'Finland', 'France', 'French Guiana', 'French Polynesia', 'French Southern and Antarctic Lands', 'Gabon', 'Gambia', 'Georgia', 'Germany', 'Ghana', 'Gibraltar', 'Greece', 'Greenland', 'Grenada', 'Guadeloupe', 'Guam', 'Guatemala', 'Guinea', 'Guinea-Bissau', 'Guyana', 'Haiti', 'Honduras', 'Hong Kong SAR', 'Hungary', 'Iceland', 'India', 'Indonesia', 'Iran', 'Iraq', 'Ireland', 'Israel', 'Italy', 'Jamaica', 'Japan', 'Jordan', 'Kazakhstan', 'Kenya', 'Kiribati', 'Korea', 'Kuwait', 'Kyrgyzstan', 'Laos', 'Latvia', 'Lebanon', 'Lesotho', 'Liberia', 'Libya', 'Liechtenstein', 'Lithuania', 'Luxembourg', 'Macao SAR', 'Macedonia, Former Yugoslav Republic of', 'Madagascar', 'Malawi', 'Malaysia', 'Maldives', 'Mali', 'Malta', 'Marshall Islands', 'Martinique', 'Mauritania', 'Mauritius', 'Mayotte', 'Mexico', 'Micronesia', 'Moldova', 'Monaco', 'Mongolia', 'Montserrat', 'Morocco', 'Mozambique', 'Myanmar', 'Namibia', 'Nauru', 'Nepal', 'Netherlands', 'New Zealand', 'Nicaragua', 'Niger', 'Nigeria', 'Norway', 'Oman', 'Pakistan', 'Palau', 'Palestine', 'Panama', 'Papua New Guinea', 'Paraguay', 'Peru', 'Philippines', 'Poland', 'Portugal', 'Puerto Rico', 'Qatar', 'Romania', 'Russia', 'Rwanda', 'Saint Kitts and Nevis', 'Saint Lucia', 'Saint Vincent and the Grenadines', 'Samoa', 'San Marino', 'Sao Tome and Principe', 'Saudi Arabia', 'Senegal', 'Serbia and Montenegro', 'Seychelles', 'Sierra Leone', 'Singapore', 'Slovakia', 'Slovenia', 'Solomon Islands', 'Somalia', 'South Africa', 'Spain', 'Sri Lanka', 'Sudan', 'Suriname', 'Swaziland', 'Sweden', 'Switzerland', 'Syria', 'Taiwan', 'Tajikistan', 'Tanzania', 'Thailand', 'Togo', 'Tonga', 'Trinidad and Tobago', 'Tunisia', 'Turkey', 'Turkmenistan', 'Tuvalu', 'Uganda', 'Ukraine', 'United Arab Emirates', 'United Kingdom', 'United States', 'Uruguay', 'Uzbekistan', 'Vanuatu', 'Vatican City', 'Venezuela', 'Vietnam', 'Yemen', 'Zambia', 'Zimbabwe'));
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('radio', $form_id));
$field_values['name'] = 'Employment Desired';
$field_values['required'] = 1;
$field_values['field_order'] = '12';
$field_values['options'] = serialize(array('Full-time', 'Part-time', 'Full- or Part- time'));
$frm_field->create($field_values);
unset($field_values);
$field_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('file', $form_id));
$field_values['name'] = 'Attach Resume';
$field_values['field_order'] = '13';
$field_values['field_options']['attach'] = 1;
$frm_field->create($field_values);
unset($field_values);
示例6: auto_add_end_section_fields
/**
* Automatically add end section fields if they don't exist (2.0 migration)
* @since 2.0
*
* @param boolean $reset_fields
*/
public static function auto_add_end_section_fields($form, $fields, &$reset_fields)
{
if (empty($fields)) {
return;
}
$end_section_values = apply_filters('frm_before_field_created', FrmFieldsHelper::setup_new_vars('end_divider', $form->id));
$open = $prev_order = false;
$add_order = 0;
$last_field = false;
foreach ($fields as $field) {
if ($prev_order === $field->field_order) {
$add_order++;
}
if ($add_order) {
$reset_fields = true;
$field->field_order = $field->field_order + $add_order;
FrmField::update($field->id, array('field_order' => $field->field_order));
}
switch ($field->type) {
case 'divider':
// create an end section if open
self::maybe_create_end_section($open, $reset_fields, $add_order, $end_section_values, $field, 'move');
// mark it open for the next end section
$open = true;
break;
case 'break':
self::maybe_create_end_section($open, $reset_fields, $add_order, $end_section_values, $field, 'move');
break;
case 'end_divider':
if (!$open) {
// the section isn't open, so this is an extra field that needs to be removed
FrmField::destroy($field->id);
$reset_fields = true;
}
// There is already an end section here, so there is no need to create one
$open = false;
}
$prev_order = $field->field_order;
$last_field = $field;
unset($field);
}
self::maybe_create_end_section($open, $reset_fields, $add_order, $end_section_values, $last_field);
}
示例7: validate
function validate($errors, $values)
{
global $frm_field;
/*
if (isset($values['item_meta'])){
foreach($values['item_meta'] as $key => $value){
$field = $frm_field->getOne($key);
if ($field && $field->type == 'hidden' and empty($value))
$errors[] = __("Hidden fields must have a value.", 'formidable');
}
}
*/
// add a user id field if the form requires one
if (isset($values['logged_in']) || isset($values['editable']) || isset($values['single_entry']) && isset($values['options']['single_entry_type']) && $values['options']['single_entry_type'] == 'user' || isset($values['options']['save_draft']) && $values['options']['save_draft'] == 1) {
$form_id = $values['id'];
$user_field = $frm_field->getAll(array('fi.form_id' => $form_id, 'type' => 'user_id'));
if (!$user_field) {
$new_values = FrmFieldsHelper::setup_new_vars('user_id', $form_id);
$new_values['name'] = __('User ID', 'formidable');
$frm_field->create($new_values);
}
}
if (isset($values['options']['auto_responder'])) {
if (!isset($values['options']['ar_email_message']) or $values['options']['ar_email_message'] == '') {
$errors[] = __("Please insert a message for your auto responder.", 'formidable');
}
if (isset($values['options']['ar_reply_to']) and !is_email(trim($values['options']['ar_reply_to']))) {
$errors[] = __("That is not a valid reply-to email address for your auto responder.", 'formidable');
}
}
return $errors;
}
示例8: validate
public static function validate($errors, $values)
{
/*
if (isset($values['item_meta'])){
foreach( $values['item_meta'] as $key => $value ) {
$field = FrmField::getOne($key);
if ($field && $field->type == 'hidden' and empty($value))
$errors[] = __( 'Hidden fields must have a value.', 'formidable' );
}
}
*/
// add a user id field if the form requires one
if (isset($values['logged_in']) || isset($values['editable']) || isset($values['single_entry']) && isset($values['options']['single_entry_type']) && $values['options']['single_entry_type'] == 'user' || isset($values['options']['save_draft']) && $values['options']['save_draft'] == 1) {
$form_id = $values['id'];
$user_field = FrmField::get_all_types_in_form($form_id, 'user_id', 1);
if (!$user_field) {
$new_values = FrmFieldsHelper::setup_new_vars('user_id', $form_id);
$new_values['name'] = __('User ID', 'formidable');
FrmField::create($new_values);
}
}
if (isset($values['options']['auto_responder'])) {
if (!isset($values['options']['ar_email_message']) || $values['options']['ar_email_message'] == '') {
$errors[] = __('Please insert a message for your auto responder.', 'formidable');
}
if (isset($values['options']['ar_reply_to']) && !is_email(trim($values['options']['ar_reply_to']))) {
$errors[] = __('That is not a valid reply-to email address for your auto responder.', 'formidable');
}
}
return $errors;
}