Exemplo n.º 1
0
            <?php 
                                                }
                                            } else {
                                                ?>
                <option value="">&mdash; <?php 
                                                _e('This data is dynamic on change', 'formidable');
                                                ?>
 &mdash;</option>
            <?php 
                                            }
                                            ?>
        </select>
    <?php 
                                        } else {
                                            if ($field['data_type'] == 'data' && is_numeric($field['hide_opt'])) {
                                                echo FrmEntryMeta::get_entry_meta_by_field($field['hide_opt'], $field['form_select']);
                                            } else {
                                                if ($field['data_type'] == 'checkbox') {
                                                    $checked_values = $field['default_value'];
                                                    if ($field['options']) {
                                                        foreach ($field['options'] as $opt_key => $opt) {
                                                            $checked = FrmAppHelper::check_selected($checked_values, $opt_key) ? ' checked="checked"' : '';
                                                            ?>
                <label for="<?php 
                                                            echo $field_name;
                                                            ?>
"><input type="checkbox" name="<?php 
                                                            echo $field_name;
                                                            ?>
[]" id="<?php 
                                                            echo $field_name;
Exemplo n.º 2
0
 /**
  * Get the displayed value for Dynamic field that imports data from a post field
  * Called from self::get_linked_field_val
  */
 private static function get_linked_post_field_val($value, $atts, $linked_field)
 {
     global $wpdb;
     $post_id = FrmDb::get_var($wpdb->prefix . 'frm_items', array('id' => $value), 'post_id');
     if ($post_id) {
         if (!isset($atts['truncate'])) {
             $atts['truncate'] = false;
         }
         $new_value = FrmProEntryMetaHelper::get_post_value($post_id, $linked_field->field_options['post_field'], $linked_field->field_options['custom_field'], array('form_id' => $linked_field->form_id, 'field' => $linked_field, 'type' => $linked_field->type, 'truncate' => $atts['truncate']));
     } else {
         $new_value = FrmEntryMeta::get_entry_meta_by_field($value, $linked_field->id);
     }
     return $new_value;
 }
Exemplo n.º 3
0
                echo esc_attr($field_name);
                ?>
" />
<?php 
            } else {
                if ($field['data_type'] == 'text' && is_numeric($field['form_select'])) {
                    $get_id = FrmAppHelper::simple_get('id');
                    if ($_POST && isset($_POST['item_meta'])) {
                        $observed_field_val = $_POST['item_meta'][$field['hide_field']];
                    } else {
                        if ($get_id) {
                            $observed_field_val = FrmEntryMeta::get_entry_meta_by_field($get_id, $field['hide_field']);
                        }
                    }
                    if (isset($observed_field_val) && is_numeric($observed_field_val)) {
                        $value = FrmEntryMeta::get_entry_meta_by_field($observed_field_val, $field['form_select']);
                    } else {
                        $value = '';
                    }
                    ?>
<input type="text" value="<?php 
                    echo esc_attr($value);
                    ?>
" name="<?php 
                    echo esc_attr($field_name);
                    ?>
" />

<?php 
                } else {
                    if ($field['data_type'] == 'checkbox') {
Exemplo n.º 4
0
 public static function validate_check_confirmation_field(&$errors, $field, $value, $args)
 {
     $conf_val = '';
     // Temporarily swtich $field->id in order to get and set the value posted in confirmation field
     $field_id = $field->id;
     $field->id = 'conf_' . $field_id;
     FrmEntriesHelper::get_posted_value($field, $conf_val, $args);
     // Switch $field->id back to original id
     $field->id = $field_id;
     unset($field_id);
     //If editing entry or if user hits Next/Submit on a draft
     if ($args['action'] == 'update') {
         //If in repeating section
         if (isset($args['key_pointer']) && ($args['key_pointer'] || $args['key_pointer'] === 0)) {
             $entry_id = str_replace('i', '', $args['key_pointer']);
         } else {
             $entry_id = $_POST && isset($_POST['id']) ? $_POST['id'] : false;
         }
         $prev_value = FrmEntryMeta::get_entry_meta_by_field($entry_id, $field->id);
         if ($prev_value != $value && $conf_val != $value) {
             $errors['conf_field' . $field->temp_id] = isset($field->field_options['conf_msg']) ? $field->field_options['conf_msg'] : __('The entered values do not match', 'formidable');
             $errors['field' . $field->temp_id] = '';
         }
     } else {
         if ($args['action'] == 'create' && $conf_val != $value) {
             //If creating entry
             $errors['conf_field' . $field->temp_id] = isset($field->field_options['conf_msg']) ? $field->field_options['conf_msg'] : __('The entered values do not match', 'formidable');
             $errors['field' . $field->temp_id] = '';
         }
     }
 }
Exemplo n.º 5
0
 public static function save_sub_entries($values, $action = 'create')
 {
     $form_id = isset($values['form_id']) ? (int) $values['form_id'] : 0;
     if (!$form_id || !isset($values['item_meta'])) {
         return $values;
     }
     $form_fields = FrmProFormsHelper::has_field('form', $form_id, false);
     $section_fields = FrmProFormsHelper::has_field('divider', $form_id, false);
     if (!$form_fields && !$section_fields) {
         // only continue if there could be sub entries
         return $values;
     }
     $form_fields = array_merge($section_fields, $form_fields);
     $new_values = $values;
     unset($new_values['item_meta']);
     // allow for multiple embeded forms
     foreach ($form_fields as $field) {
         if (!isset($values['item_meta'][$field->id]) || !isset($field->field_options['form_select']) || !isset($values['item_meta'][$field->id]['form'])) {
             // don't continue if we don't know which form to insert the sub entries into
             unset($values['item_meta'][$field->id]);
             continue;
         }
         if ('divider' == $field->type && !FrmField::is_repeating_field($field)) {
             // only create sub entries for repeatable sections
             continue;
         }
         $field_values = $values['item_meta'][$field->id];
         $sub_form_id = $field->field_options['form_select'];
         unset($field_values['form']);
         if ($action != 'create' && isset($field_values['id'])) {
             $old_ids = FrmEntryMeta::get_entry_meta_by_field($values['id'], $field->id);
             $old_ids = array_filter((array) $old_ids, 'is_numeric');
             unset($field_values['id']);
         } else {
             $old_ids = array();
         }
         $sub_ids = array();
         foreach ($field_values as $k => $v) {
             $entry_values = $new_values;
             $entry_values['form_id'] = $sub_form_id;
             $entry_values['item_meta'] = (array) $v;
             $entry_values['parent_item_id'] = isset($values['id']) ? $values['id'] : 0;
             $entry_values['parent_form_id'] = $form_id;
             // include a nonce just to be sure the parent_form_id is legit
             $entry_values['parent_nonce'] = wp_create_nonce('parent');
             // set values for later user (file upload and tags fields)
             $_POST['item_meta']['key_pointer'] = $k;
             $_POST['item_meta']['parent_field'] = $field->id;
             if (!is_numeric($k) && in_array(str_replace('i', '', $k), $old_ids)) {
                 // update existing sub entries
                 $entry_values['id'] = str_replace('i', '', $k);
                 FrmEntry::update($entry_values['id'], $entry_values);
                 $sub_id = $entry_values['id'];
             } else {
                 // create new sub entries
                 $sub_id = FrmEntry::create($entry_values);
             }
             if ($sub_id) {
                 $sub_ids[] = $sub_id;
             }
             unset($k, $v, $entry_values, $sub_id);
         }
         $values['item_meta'][$field->id] = $sub_ids;
         // array of sub entry ids
         $old_ids = array_diff($old_ids, $sub_ids);
         if (!empty($old_ids)) {
             // delete entries that were removed from section
             foreach ($old_ids as $old_id) {
                 FrmEntry::destroy($old_id);
             }
         }
         unset($field);
     }
     return $values;
 }