public function render($stat_id = null) { global $rm_form_diary; echo '<div class="rmagic">'; //$this->form_number = $rm_form_diary[$this->form_id]; $form = new Form('form_' . $this->form_id . "_" . $this->form_number); $form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "action" => "", "class" => "rmagic-form", "name" => "rm_form", "number" => $this->form_number, "view" => new View_UserForm(), "style" => isset($this->form_options->style_form) ? $this->form_options->style_form : null)); //Render content above the form if (!empty($this->form_options->form_custom_text)) { $form->addElement(new Element_HTML('<div class="rmheader">' . $this->form_options->form_custom_text . '</div>')); } if ($this->is_expired()) { if ($this->form_options->form_message_after_expiry) { echo $this->form_options->form_message_after_expiry; } else { echo '<div class="rm-no-default-from-notification">' . RM_UI_Strings::get('MSG_FORM_EXPIRY') . '</div>'; } echo '</div>'; return; } if ($stat_id) { $form->addElement(new Element_HTML('<div id="rm_stat_container" style="display:none">')); $form->addElement(new Element_Number('RM_Stats', 'stat_id', array('value' => $stat_id, 'style' => 'display:none'))); $form->addElement(new Element_HTML('</div>')); } parent::pre_render(); $this->base_render($form); parent::post_render(); echo '</div>'; }
/** * {@inheritDoc} */ protected function configure() { $this->addOption('first_key', 'first'); $this->addOption('second_key', 'second'); parent::configure(); $field = clone $this->prototype; $field->setKey($this->getOption('first_key')); $field->setPropertyPath($this->getOption('first_key')); $this->add($field); $field = clone $this->prototype; $field->setKey($this->getOption('second_key')); $field->setPropertyPath($this->getOption('second_key')); $this->add($field); }
/** * @internal Plugin Template File [For user forms] * * This file renders the user made custom forms of the plugin on the front end * using the shortcode. * */ ?> <div class="rmagic"> <?php if ($data->fields_data) { $form = new Form('form_' . $data->form->form_id); $form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "action" => "", "class" => "rmagic-form")); //Check if user exists if ($data->user_exists) { echo '<div class="rm_user_exists_alert">' . RM_UI_Strings::get('USER_EXISTS') . '</div>'; } ?> <!--Dialogue Box Starts--> <div class="rmcontent"> <?php //Create stat_id field if ($data->stat_id) { $form->addElement(new Element_HTML('<div id="rm_stat_container" style="display:none">')); $form->addElement(new Element_Number('RM_Stats', 'stat_id', array('value' => $data->stat_id, 'style' => 'display:none'))); $form->addElement(new Element_HTML('</div>')); } if (!empty($data->form->form_options->form_custom_text)) {
function buddyforms_form_html($args) { global $buddyforms, $bf_form_error, $bf_submit_button; // First check if any form error exist if (!empty($bf_form_error)) { echo '<div class="error alert">' . $bf_form_error . '</div>'; return; } // Extract the form args extract(shortcode_atts(array('post_type' => '', 'the_post' => 0, 'customfields' => false, 'post_id' => false, 'revision_id' => false, 'post_parent' => 0, 'redirect_to' => esc_url($_SERVER['REQUEST_URI']), 'form_slug' => '', 'form_notice' => ''), $args)); session_id('buddyforms-create-edit-form'); $form_slug_js = str_replace('-', '_', $form_slug); // Form HTML Start. The Form is rendered as last step. $form_html = '<div class="the_buddyforms_form the_buddyforms_form_' . $form_slug . '">'; // Create the needed Validation JS. // To have multiple forms on one page work nicely we added the js inline for now. // Todo: create a separate function and add the js correctly. $form_html .= ' <script> var ajaxurl = "' . admin_url('admin-ajax.php') . '"; jQuery(function() { var validator_' . $form_slug_js . ' = jQuery("#editpost_' . $form_slug . '").submit(function() { if(jQuery(\'textarea\').length > 0) { // update underlying textarea before submit validation tinyMCE.triggerSave(); } }).validate({ ignore: "", rules: { '; if (isset($buddyforms[$form_slug]['form_fields'])) { foreach ($buddyforms[$form_slug]['form_fields'] as $key => $form_field) { if (isset($form_field['required'])) { $field_slug = str_replace("-", "", $form_field['slug']); if ($field_slug) { $form_html .= $field_slug . ': { required: true,'; if (isset($form_field['validation_min']) && $form_field['validation_min'] > 0) { $form_html .= 'min: ' . $form_field['validation_min'] . ','; } if (isset($form_field['validation_max']) && $form_field['validation_max'] > 0) { $form_html .= 'max: ' . $form_field['validation_max'] . ','; } if (isset($form_field['validation_minlength']) && $form_field['validation_minlength'] > 0) { $form_html .= 'minlength: ' . $form_field['validation_minlength'] . ','; } if (isset($form_field['validation_maxlength']) && $form_field['validation_maxlength'] > 0) { $form_html .= 'maxlength: ' . $form_field['validation_maxlength'] . ','; } $form_html .= '},'; } } } } $form_html .= '}, messages: { '; if (isset($buddyforms[$form_slug]['form_fields'])) { foreach ($buddyforms[$form_slug]['form_fields'] as $key => $form_field) { if (isset($form_field['required'])) { $validation_error_message = __('This field is required.', 'buddyforms'); if (isset($form_field['validation_error_message'])) { $validation_error_message = $form_field['validation_error_message']; } $field_slug = str_replace("-", "", $form_field['slug']); if ($field_slug) { $form_html .= $field_slug . ': { required: "' . $validation_error_message . '", },'; } } } } $form_html .= '},'; $form_html .= 'errorPlacement: function(label, element) { // position error label after generated textarea if (element.is("textarea")) { jQuery("#editpost_title").prev().css(\'color\',\'red\'); label.insertBefore("#editpost_content"); } else { label.insertAfter(element) } } }); validator_' . $form_slug_js . '.focusInvalid = function() { // put focus on tinymce on submit validation if (this.settings.focusInvalid) { try { var toFocus = jQuery(this.findLastActive() || this.errorList.length && this.errorList[0].element || []); if (toFocus.is("textarea")) { tinyMCE.get(toFocus.attr("id")).focus(); } else { toFocus.filter(":visible").focus(); } } catch (e) { // ignore IE throwing errors when focusing hidden elements } } } }); </script>'; if (!is_user_logged_in()) { $wp_login_form = '<h3>' . __('You need to be logged in to use this Form', 'buddyforms') . '</h3>'; $wp_login_form .= wp_login_form(array('echo' => false)); $wp_login_form = apply_filters('buddyforms_wp_login_form', $wp_login_form); return $wp_login_form; } $user_can_edit = false; if (empty($post_id) && current_user_can('buddyforms_' . $form_slug . '_create')) { $user_can_edit = true; } elseif (!empty($post_id) && current_user_can('buddyforms_' . $form_slug . '_edit')) { $user_can_edit = true; } $user_can_edit = apply_filters('buddyforms_user_can_edit', $user_can_edit); if ($user_can_edit == false) { $error_message = __('You do not have the required user role to use this form', 'buddyforms'); return '<div class="error alert">' . $error_message . '</div>'; //das sieht nicht sauber aus } $form_html .= '<div id="form_message_' . $form_slug . '">' . $form_notice . '</div>'; $form_html .= '<div class="form_wrapper">'; // Create the form object $form = new Form("editpost_" . $form_slug); // Set the form attribute $form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "action" => $redirect_to, "view" => new View_Vertical(), 'class' => 'standard-form')); $form->addElement(new Element_HTML(do_action('template_notices'))); $form->addElement(new Element_HTML(wp_nonce_field('buddyforms_form_nonce', '_wpnonce', true, false))); $form->addElement(new Element_Hidden("redirect_to", $redirect_to)); $form->addElement(new Element_Hidden("post_id", $post_id)); $form->addElement(new Element_Hidden("revision_id", $revision_id)); $form->addElement(new Element_Hidden("post_parent", $post_parent)); $form->addElement(new Element_Hidden("form_slug", $form_slug)); $form->addElement(new Element_Hidden("bf_post_type", $post_type)); if (isset($buddyforms[$form_slug]['bf_ajax'])) { $form->addElement(new Element_Hidden("ajax", 'off')); } // if the form has custom field to save as post meta data they get displayed here bf_form_elements($form, $args); $form->addElement(new Element_Hidden("submitted", 'true', array('value' => 'true', 'id' => "submitted"))); $form->addElement(new Element_Hidden("bf_submitted", 'true', array('value' => 'true', 'id' => "submitted"))); $bf_submit_button = new Element_Button(__('Submit', 'buddyforms'), 'submit', array('id' => $form_slug, 'class' => 'bf-submit', 'name' => 'submitted')); $form = apply_filters('buddyforms_create_edit_form_button', $form, $form_slug, $post_id); if ($bf_submit_button) { $form->addElement($bf_submit_button); } $form = apply_filters('bf_form_before_render', $form, $args); // That's it! render the form! ob_start(); $form->render(); $form_html .= ob_get_contents(); ob_clean(); $form_html .= '<div class="bf_modal"></div></div>'; // If Form Revision is enabled Display the revision posts under the form if (isset($buddyforms[$form_slug]['revision']) && $post_id != 0) { ob_start(); buddyforms_wp_list_post_revisions($post_id); $form_html .= ob_get_contents(); ob_clean(); } $form_html .= '</div>'; return $form_html; }
<div class="shortcode_notification ext_na_error_notice"><p class="rm-notice-para"><?php echo RM_UI_Strings::get('RM_ERROR_PHP_4.5'); ?> </p></div> <?php } ?> <div class="rmagic"> <!--Dialogue Box Starts--> <div class="rmcontent"> <?php $form = new Form("form_sett_cc"); $form->configure(array("prevent" => array("bootstrap", "jQuery"), "action" => "")); if (isset($data->form_id)) { $form->addElement(new Element_HTML('<div class="rmheader">' . $data->form_name . '</div>')); $form->addElement(new Element_HTML('<div class="rmsettingtitle">' . RM_UI_Strings::get('LABEL_CONSTANT_CONTACT_OPTION') . '</div>')); $form->addElement(new Element_Hidden("form_id", $data->form_id)); } else { $form->addElement(new Element_HTML('<div class="rmheader">' . RM_UI_Strings::get("TITLE_NEW_FORM_PAGE") . '</div>')); } $form->addElement(new Element_Checkbox(RM_UI_Strings::get('LABEL_CONSTANT_CONTACT_OPTION'), "enable_ccontact", array(1 => ""), array("id" => "id_rm_enable_cc_cb", "class" => "id_rm_enable_cc_cb", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('MSG_BUY_PRO_BOTH_INLINE')))); $form->addElement(new Element_HTML('<div class="childfieldsrow" id="id_rm_enable_cc_cb_childfieldsrow">')); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LABEL_CC_LIST') . ":</b>", "cc_list", array(0 => "cc_list"), array("id" => "cc_list", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FORM_CC_LIST')))); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LABEL_EMAIL') . ":</b>", "email", array(0 => "Email"), array("id" => "email", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FIELD_CC')))); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('FIRST_NAME') . ":</b>", "first_name", array(0 => "first name"), array("id" => "first_name", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FIELD_CC')))); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LAST_NAME') . ":</b>", "last_name", array(0 => "last name"), array("id" => "last_name", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FIELD_CC')))); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LABEL_MNAME') . ":</b>", "middle_name", array(0 => "middle name"), array("id" => "middle_name", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FIELD_CC')))); $form->addElement(new Element_Select("<b>" . RM_UI_Strings::get('LABEL_COMPANY') . ":</b>", "company_name", array(0 => "company name"), array("id" => "company_name", "disabled" => "disabled", "value" => "", "longDesc" => RM_UI_Strings::get('HELP_ADD_FIELD_CC'))));
public function render($extra_data_may_needed_in_child_class = null) { global $rm_form_diary; echo '<div class="rmagic">'; //$this->form_number = $rm_form_diary[$this->form_id]; $form = new Form('form_' . $this->form_id . "_" . $this->form_number); $form->configure(array("prevent" => array("bootstrap", "jQuery", "focus"), "action" => "", "class" => "rmagic-form", "name" => "rm_form", "view" => new View_UserForm(), "number" => $this->form_number, "style" => isset($this->form_options->style_form) ? $this->form_options->style_form : null)); //Render content above the form if (!empty($this->form_options->form_custom_text)) { $form->addElement(new Element_HTML('<div class="rmheader">' . $this->form_options->form_custom_text . '</div>')); } if (!$this->is_expired()) { $this->pre_render(); $this->base_render($form); $this->post_render(); } else { if ($this->form_options->form_message_after_expiry) { echo $this->form_options->form_message_after_expiry; } else { echo RM_UI_Strings::get('MSG_FORM_EXPIRY'); } } echo '</div>'; }
public static function renderArray($formId, $items, $values, $buttons = 1) { $form = new Form($formId); $opts = array(); if (empty($items['ajax'])) { $items["ajax"] = array("Hidden", "", "", array("value" => "false")); } else { $opts['ajax'] = true; $opts['ajaxCallback'] = $items['ajax']; unset($items['ajax']); } if ($buttons) { $items["noneSubmitButton"] = array("Button", "Submit"); if ($buttons != Form::$SUBMIT) { if (!empty($values['id'])) { if (is_array($buttons)) { foreach ($buttons as $k => $b) { $items[$k] = $b; } $items['noneRemoveButton'] = array("Button", "Remove", "button", array("class" => "btn-danger", "data-toggle" => "modal", "data-target" => "#rmConfirm")); } } if (!empty($items['ajax'])) { $items["noneCancelButton"] = array("Button", "Cancel", "button", array("onclick" => "history.go(-1);")); } } } $form->configure($opts); $form->addElements($items); if (!empty($values)) { $form->setValues($values); } $form->render(); }
</div> btn_html; ?> <div class="rmagic"> <!--Dialogue Box Starts--> <div class="rmcontent"> <?php $pages = get_pages(); $wp_pages = RM_Utilities::wp_pages_dropdown(); $form = new Form("options_fab"); $form->configure(array("prevent" => array("bootstrap", "jQuery"), "action" => "", "enctype" => "multipart/form-data")); $form->addElement(new Element_HTML('<div class="rmheader">' . RM_UI_Strings::get('GLOBAL_SETTINGS_FAB') . '</div>')); $form->addElement(new Element_Checkbox(RM_UI_Strings::get('LABEL_SHOW_FLOATING_ICON'), "display_floating_action_btn", array("yes" => ''), $data['display_floating_action_btn'] == 'yes' ? array("value" => "yes", "longDesc" => RM_UI_Strings::get('HELP_SHOW_FLOATING_ICON')) : array("longDesc" => RM_UI_Strings::get('HELP_SHOW_FLOATING_ICON')))); $form->addElement(new Element_HTML($media_btn_html)); $form->addElement(new Element_HTML('<div class="rmnotice">' . RM_UI_Strings::get('NOTE_MAGIC_PANEL_STYLING') . '</div>')); $form->addElement(new Element_HTMLL('← Cancel', '?page=rm_options_manage', array('class' => 'cancel'))); $form->addElement(new Element_Button(RM_UI_Strings::get('LABEL_SAVE'))); $form->render(); ?> </div> </div> <?php wp_enqueue_media(); ?>
function buddyforms_editor_button_inline_content() { global $buddyforms; if (!is_admin()) { return; } ?> <div id="buddyforms_popup_container" style="display:none;"> <h2></h2> <?php // Get all post types $args = array('public' => true, 'show_ui' => true); $output = 'names'; // names or objects, note names is the default $operator = 'and'; // 'and' or 'or' $post_types = get_post_types($args, $output, $operator); $post_types_none['none'] = 'none'; $post_types = array_merge($post_types_none, $post_types); // // Insert Form // $form = new Form("buddyforms_add_form"); $form->configure(array("prevent" => array("bootstrap", "jQuery"), "action" => $_SERVER['REQUEST_URI'], "view" => new View_Inline())); $the_forms['none'] = 'Select Form'; foreach ($buddyforms as $key => $buddyform) { $the_forms[$buddyform['slug']] = $buddyform['slug']; } $form->addElement(new Element_Select("<h3>" . __('Insert Form', 'buddyforms') . "</h3><br>", "buddyforms_add_form", $the_forms, array('class' => 'buddyforms_add_form'))); $form->addElement(new Element_HTML(' <a href="#" class="buddyforms-button-insert-form button">' . __('Insert into Post', 'buddyforms') . '</a>')); $form->render(); // // Insert Navigation // $form = new Form("buddyforms_add_nav"); $form->configure(array("prevent" => array("bootstrap", "jQuery"), "action" => $_SERVER['REQUEST_URI'], "view" => new View_Inline())); $button_type['none'] = 'Insert Navigation'; $button_type['buddyforms_nav'] = 'View - Add New'; $button_type['buddyforms_button_view_posts'] = 'View Posts'; $button_type['buddyforms_button_add_new'] = 'Add New'; $form->addElement(new Element_Select("<h3>" . __('Button Type', 'buddyforms') . "</h3><br>", "buddyforms_insert_nav", $button_type, array('class' => 'buddyforms_insert_nav'))); $form->addElement(new Element_Select("", "buddyforms_select_form", $the_forms, array('class' => 'buddyforms_select_form'))); $form->addElement(new Element_HTML(' <a href="#" class="buddyforms-button-insert-nav button">' . __('Insert into Post', 'buddyforms') . '</a>')); $form->render(); // // Insert Posts // $form = new Form("buddyforms_view_posts"); $form->configure(array("prevent" => array("bootstrap", "jQuery"), "action" => $_SERVER['REQUEST_URI'], "view" => new View_Inline())); $view_type['none'] = 'Filter Posts'; $view_type['buddyforms_list_all'] = 'All User'; $view_type['buddyforms_the_loop'] = 'Displayed User'; $form->addElement(new Element_Select("<h3>" . __('List Posts', 'buddyforms') . "</h3><br>", "buddyforms_view_posts", $view_type, array('class' => 'buddyforms_view_posts'))); $form->addElement(new Element_Select("", "buddyforms_select_form_posts", $the_forms, array('class' => 'buddyforms_select_form_posts'))); $form->addElement(new Element_HTML(' <a href="#" class="buddyforms-button-insert-posts button">' . __('Insert into Post', 'buddyforms') . '</a>')); $form->render(); ?> </div> <?php }