public function test_display_flat_array()
    {
        $form = new EE_Form_Section_Proper(array('name' => 'form', 'subsections' => array('input1' => new EE_Checkbox_Multi_Input(array('foo' => 'Foo', 'bar' => 'Bar', "baz'em" => 'Baz')))));
        $input = $form->get_input('input1');
        $expected_output = '
<label for="form-input1-foo" id="form-input1-foo-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-foo" class="" style="" value="foo">&nbsp;Foo
</label>
<label for="form-input1-bar" id="form-input1-bar-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-bar" class="" style="" value="bar">&nbsp;Bar
</label>
<label for="form-input1-bazem" id="form-input1-bazem-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-bazem" class="" style="" value="baz&#039;em">&nbsp;Baz
</label>';
        $this->assertEquals($expected_output, $input->get_html_for_input());
        //now if we set the default, does it get selected?
        $form->populate_defaults(array('input1' => array("baz'em", 'bar')));
        $this->assertEquals(array("baz'em", 'bar'), $input->normalized_value());
        $this->assertEquals(array("baz'em", 'bar'), $input->raw_value());
        $expected_output2 = '
<label for="form-input1-foo" id="form-input1-foo-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-foo" class="" style="" value="foo">&nbsp;Foo
</label>
<label for="form-input1-bar" id="form-input1-bar-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-bar" class="" style="" value="bar" checked="checked">&nbsp;Bar
</label>
<label for="form-input1-bazem" id="form-input1-bazem-lbl" class="ee-checkbox-label-after micro-lbl">
	<input type="checkbox" name="form[input1][]" id="form-input1-bazem" class="" style="" value="baz&#039;em" checked="checked">&nbsp;Baz
</label>';
        $this->assertEquals($expected_output2, $input->get_html_for_input());
    }
    function ee_show_billing_info_cleaned(EE_Form_Section_Proper $form_section, $found_cc_data = false)
    {
        foreach ($form_section->subsections() as $subsection) {
            if ($subsection instanceof EE_Form_Input_Base) {
                if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_All_Sensitive_Data_Removal || $subsection->get_sensitive_data_removal_strategy() instanceof EE_CCV_Sensitive_Data_Removal) {
                    continue;
                }
                if ($subsection->get_sensitive_data_removal_strategy() instanceof EE_Credit_Card_Sensitive_Data_Removal) {
                    $found_cc_data = true;
                }
                ?>
					<div class="clearfix">
						<span class="admin-side-mbox-label-spn lt-grey-txt float-left"><?php 
                echo $subsection->get_html_for_label();
                ?>
</span><?php 
                echo $subsection->pretty_value();
                ?>
					</div><?php 
            } elseif ($subsection instanceof EE_Form_Section_Proper) {
                $found_cc_data = ee_show_billing_info_cleaned($subsection, $found_cc_data);
            }
        }
        return $found_cc_data;
    }
コード例 #3
0
 public function test_form_data_present_in__custom_html_name()
 {
     $granparent_form = new EE_Form_Section_Proper(array('name' => 'grandparent', 'subsections' => array('parent' => new EE_Form_Section_Proper(array('subsections' => array('form' => new EE_Form_Section_Proper(array('subsections' => array('input' => new EE_Text_Input(array('html_name' => 'foo[bar][monkey]')), 'input2' => new EE_Text_Input(array('html_name' => 'fluff[baz][lizard]')))))))))));
     $req_data_bad = array('grandparent' => array('parent' => array('form' => array('input' => 'value', 'input2' => 'value2'))));
     $req_data_good = array('foo' => array('bar' => array('monkey' => 'poop')), 'fluff' => array('baz' => array('lizard' => 'tail')));
     $input = $granparent_form->get_subsection('parent')->get_subsection('form')->get_subsection('input');
     $this->assertTrue($input->form_data_present_in($req_data_good));
     $this->assertFalse($input->form_data_present_in($req_data_bad));
 }
 /**
  * Lays out a row for the subsection
  * @param EE_Form_Section_Proper $form_section
  * @return string
  */
 public function layout_subsection($form_section)
 {
     $html = '';
     if ($form_section instanceof EE_Form_Section_HTML) {
         $html .= $form_section->get_html_and_js();
     } else {
         $html .= EEH_HTML::tr(EEH_HTML::td($form_section->get_html_and_js(), '', '', '', 'colspan="2"'));
     }
     return $html;
 }
 /**
  * Lays out a row for the subsection
  * @param EE_Form_Section_Proper $form_section
  * @return string
  */
 public function layout_subsection($form_section)
 {
     if ($form_section instanceof EE_Form_Section_Proper) {
         return EEH_HTML::no_row($form_section->get_html(), 2);
     } else {
         if ($form_section instanceof EE_Form_Section_HTML) {
             return $form_section->get_html();
         }
     }
     return '';
 }
    /**
     * @group 7121
     */
    function test_display__normalizing_as_string()
    {
        $form = new EE_Form_Section_Proper(array('name' => 'test', 'subsections' => array('use_captcha' => new EE_Radio_Button_Input(array("yes ma'am" => __('Yes', 'event_espresso'), "no ma'am" => __('No', 'event_espresso')), array('html_label_text' => __('Use reCAPTCHA', 'event_espresso'), 'default' => "yes ma'am")))));
        $this->assertEquals("yes ma'am", $form->get_input('use_captcha')->normalized_value());
        $this->assertEquals("yes ma'am", $form->get_input('use_captcha')->raw_value());
        $this->assertEquals('
<label for="test-use-captcha-yesmaam" id="test-use-captcha-yesmaam-lbl" class="ee-radio-label-after micro-lbl">
	<input id="test-use-captcha-yesmaam" name="test[use_captcha]" class="" style="" type="radio" value="yes ma&#039;am" checked="checked">&nbsp;Yes
</label>
<label for="test-use-captcha-nomaam" id="test-use-captcha-nomaam-lbl" class="ee-radio-label-after micro-lbl">
	<input id="test-use-captcha-nomaam" name="test[use_captcha]" class="" style="" type="radio" value="no ma&#039;am">&nbsp;No
</label>
<div class="clear-float">
</div>', $form->get_input('use_captcha')->get_html_for_input());
        $form->populate_defaults(array('use_captcha' => "no ma'am"));
        //the first option should be selected now
        $this->assertEquals("no ma'am", $form->get_input('use_captcha')->normalized_value());
        $this->assertEquals("no ma'am", $form->get_input('use_captcha')->raw_value());
        $this->assertEquals('
<label for="test-use-captcha-yesmaam" id="test-use-captcha-yesmaam-lbl" class="ee-radio-label-after micro-lbl">
	<input id="test-use-captcha-yesmaam" name="test[use_captcha]" class="" style="" type="radio" value="yes ma&#039;am">&nbsp;Yes
</label>
<label for="test-use-captcha-nomaam" id="test-use-captcha-nomaam-lbl" class="ee-radio-label-after micro-lbl">
	<input id="test-use-captcha-nomaam" name="test[use_captcha]" class="" style="" type="radio" value="no ma&#039;am" checked="checked">&nbsp;No
</label>
<div class="clear-float">
</div>', $form->get_input('use_captcha')->get_html_for_input());
    }
 /**
  * @group 7121
  */
 public function test_normalized_value_int()
 {
     $form = new EE_Form_Section_Proper(array('name' => 'test', 'subsections' => array('use_captcha' => new EE_Radio_Button_Input(array(1 => __('Yes', 'event_espresso'), 0 => __('No', 'event_espresso')), array('html_label_text' => __('Use reCAPTCHA', 'event_espresso'), 'default' => isset(EE_Registry::instance()->CFG->registration->use_captcha) ? EE_Registry::instance()->CFG->registration->use_captcha : FALSE, 'normalization_strategy' => new EE_Int_Normalization())))));
     $form->receive_form_submission(array('test' => array('use_captcha' => '1')));
     $this->assertTrue($form->is_valid());
     $this->assertTrue(1 === $form->get_input('use_captcha')->normalized_value());
     $this->assertTrue('1' === $form->get_input('use_captcha')->raw_value());
     $form->receive_form_submission(array('test' => array('use_captcha' => '0')));
     $this->assertTrue($form->is_valid());
     $this->assertTrue(0 === $form->get_input('use_captcha')->normalized_value());
     $this->assertTrue('0' === $form->get_input('use_captcha')->raw_value());
 }
コード例 #8
0
 function _validate()
 {
     parent::_validate();
     if ($this->_subsections['shirt_size']->normalized_value() == 's' && $this->_subsections['year_4']->normalized_value() < 2010) {
         $this->add_validation_error(__("If you want a small shirt, you should be born after 2010. Otherwise theyre just too big", 'event_espresso'), 'too-old');
     }
 }
 function test_many_valued()
 {
     //create a form with radio button in it.
     $form = new EE_Form_Section_Proper(array('name' => 'test1', 'subsections' => array('checkbox1' => new EE_Checkbox_Multi_Input(array('option1' => 'Option 1', 'option2' => 'Option 2')))));
     $checkbox = $form->get_input('checkbox1');
     //that radio button's normalization strategy is correct
     $this->assertInstanceOf('EE_Checkbox_Multi_Input', $checkbox);
     $this->assertInstanceOf('EE_Many_Valued_Normalization', $checkbox->get_normalization_strategy());
     //and that when it receives input, it sets it correctly
     $form->receive_form_submission(array('checkbox1' => array('option1')));
     $this->assertTrue($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => array('option_nonexistent')));
     $this->assertFalse($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => 'option1'));
     $this->assertTrue($form->is_valid());
     $form->receive_form_submission(array('checkbox1' => 'option_nonexistent'));
     $this->assertFalse($form->is_valid());
 }
コード例 #10
0
 /**
  * Sets the html_id to its default value, if none was specified in the constructor.
  * Calculation involves using the name and the parent's html id
  * return void
  */
 protected function _set_default_html_id_if_empty()
 {
     if (!$this->_html_id) {
         if ($this->_parent_section && $this->_parent_section instanceof EE_Form_Section_Proper) {
             $this->_html_id = $this->_parent_section->html_id() . '-' . $this->_prep_name_for_html_id($this->name());
         } else {
             $this->_html_id = $this->_prep_name_for_html_id($this->name());
         }
     }
 }
 /**
  * Does an action and hook onto the end of teh form
  * @param string $html
  * @return string
  */
 public function add_form_section_hooks_and_filters($html)
 {
     // replace dashes and spaces with underscores
     $hook_name = str_replace(array('-', ' '), '_', $this->_form_section->html_id());
     do_action('AHEE__Form_Section_Layout__' . $hook_name, $this->_form_section);
     $html = apply_filters('AFEE__Form_Section_Layout__' . $hook_name . '__html', $html, $this->_form_section);
     $html .= EEH_HTML::nl() . '<!-- AHEE__Form_Section_Layout__' . $hook_name . '__html -->';
     $html .= EEH_HTML::nl() . '<!-- AFEE__Form_Section_Layout__' . $hook_name . ' -->';
     return $html;
 }
 /**
  *
  * @param EE_Registration $reg
  * @param array $options
  */
 public function __construct(EE_Registration $reg, $options = array())
 {
     $this->_registration = $reg;
     if (!isset($options['layout_strategy'])) {
         $options['layout_strategy'] = new EE_Admin_Two_Column_Layout();
     }
     if (!isset($options['html_id'])) {
         $options['html_id'] = 'reg-admin-attendee-questions-frm';
     }
     $this->build_form_from_registration();
     parent::__construct($options);
 }
コード例 #13
0
 /**
  * Gets the form for displaying to attendees where they can enter their billing info
  * which will be sent to teh gateway (can be null)
  *
  * @param \EE_Transaction $transaction
  * @param array $extra_args
  * @return \EE_Billing_Attendee_Info_Form|\EE_Billing_Info_Form|null
  */
 public function billing_form(EE_Transaction $transaction = NULL, $extra_args = array())
 {
     // has billing form already been regenerated ? or overwrite cache?
     if (!$this->_billing_form instanceof EE_Billing_Info_Form || !$this->_cache_billing_form) {
         $this->_billing_form = $this->generate_new_billing_form($transaction, $extra_args);
     }
     //if we know who the attendee is, and this is a billing form
     //that uses attendee info, populate it
     if ($this->_billing_form instanceof EE_Billing_Attendee_Info_Form && $transaction instanceof EE_Transaction && $transaction->primary_registration() instanceof EE_Registration && $transaction->primary_registration()->attendee() instanceof EE_Attendee) {
         $this->_billing_form->populate_from_attendee($transaction->primary_registration()->attendee());
     }
     return $this->_billing_form;
 }
    public function test_display_flat_array()
    {
        $form = new EE_Form_Section_Proper(array('name' => 'form', 'subsections' => array('input1' => new EE_Select_Multiple_Input(array('foo' => 'Foo', 'bar' => 'Bar', "baz'em" => 'Baz')))));
        $input = $form->get_input('input1');
        $expected_output = '
<select multiple id="form-input1" name="form[input1][]" class="" style="">
	<option value="foo">Foo</option>
	<option value="bar">Bar</option>
	<option value="baz&#039;em">Baz</option>
</select>';
        $this->assertEquals($expected_output, $input->get_html_for_input());
        //now if we set the default, does it get selected?
        $form->populate_defaults(array('input1' => array("baz'em", 'bar')));
        $this->assertEquals(array("baz'em", 'bar'), $input->normalized_value());
        $this->assertEquals(array("baz'em", 'bar'), $input->raw_value());
        $expected_output2 = '
<select multiple id="form-input1" name="form[input1][]" class="" style="">
	<option value="foo">Foo</option>
	<option value="bar" selected="selected">Bar</option>
	<option value="baz&#039;em" selected="selected">Baz</option>
</select>';
        $this->assertEquals($expected_output2, $input->get_html_for_input());
    }
 /**
  * get_billing_form_html_for_payment_method
  *
  * @access public
  * @return string
  */
 public function get_billing_form_html_for_payment_method()
 {
     // how have they chosen to pay?
     $this->checkout->selected_method_of_payment = $this->_get_selected_method_of_payment(TRUE);
     $this->checkout->payment_method = $this->_get_payment_method_for_selected_method_of_payment();
     if (!$this->checkout->payment_method instanceof EE_Payment_Method) {
         return FALSE;
     }
     if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
         EE_Error::add_success(apply_filters('FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name())));
     }
     // now generate billing form for selected method of payment
     $payment_method_billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method, FALSE);
     // fill form with attendee info if applicable
     if ($payment_method_billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
         $payment_method_billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
     }
     // and debug content
     if ($payment_method_billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
         $payment_method_billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($payment_method_billing_form);
     }
     $billing_info = $payment_method_billing_form instanceof EE_Form_Section_Proper ? $payment_method_billing_form->get_html() : '';
     $this->checkout->json_response->set_return_data(array('payment_method_info' => $billing_info));
     // localize validation rules for main form
     $this->checkout->current_step->reg_form->localize_validation_rules();
     $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
     return TRUE;
 }
コード例 #16
0
 /**
  * @return array
  */
 public static function reset_js_localization()
 {
     self::$_js_localization = array();
 }
コード例 #17
0
 /**
  *    reset_for_current_request
  *
  * @access    public
  * @return    void
  */
 public function reset_for_current_request()
 {
     $this->continue_reg = apply_filters('FHEE__EE_Checkout___construct___continue_reg', true);
     $this->admin_request = is_admin() && !EE_Registry::instance()->REQ->front_ajax;
     $this->continue_reg = true;
     $this->redirect = false;
     // don't reset the cached redirect form if we're about to be asked to display it !!!
     if (EE_Registry::instance()->REQ->get('action', 'display_spco_reg_step') !== 'redirect_form') {
         $this->redirect_form = '';
     }
     $this->redirect_url = '';
     $this->json_response = new EE_SPCO_JSON_Response();
     EE_Form_Section_Proper::reset_js_localization();
 }
 public function load_scripts_styles_new_registration()
 {
     wp_register_script('ee-spco-for-admin', REG_ASSETS_URL . 'spco_for_admin.js', array('underscore', 'jquery'), EVENT_ESPRESSO_VERSION, TRUE);
     wp_enqueue_script('ee-spco-for-admin');
     add_filter('FHEE__EED_Ticket_Selector__load_tckt_slctr_assets', '__return_true');
     EE_Form_Section_Proper::wp_enqueue_scripts();
     EED_Ticket_Selector::load_tckt_slctr_assets();
     EE_Datepicker_Input::enqueue_styles_and_scripts();
 }
コード例 #19
0
 /**
  * Simplifies the form to merely reproduce 4.1's gateway settings functionality
  *
  * @param EE_Form_Section_Proper $form_section
  * @param string                 $payment_method_name
  * @return \EE_Payment_Method_Form
  * @throws \EE_Error
  */
 protected function _simplify_form($form_section, $payment_method_name = '')
 {
     if ($form_section instanceof EE_Payment_Method_Form) {
         $form_section->exclude(array('PMD_type', 'PMD_slug', 'PMD_wp_user', 'Currency'));
         return $form_section;
     } else {
         throw new EE_Error(sprintf(__('The EE_Payment_Method_Form for the "%1$s" payment method is missing or invalid.', 'event_espresso'), $payment_method_name));
     }
 }
コード例 #20
0
 /**
  * After the form section is initially created, call this to sanitize the data in the submission
  * which relates to this form section, validate it, and set it as properties on the form.
  * @param array $req_data should usually be $_REQUEST (the default). However, you CAN
  * supply a different array. Consider using set_defaults() instead however. (If you rendered
  * the form in the page using echo $form_x->get_html() the inputs will have the correct name
  * in the request data for this function to find them and populate the form with them.
  * If you have a flat form (with only input subsections), you can supply a flat array where keys
  * are the form input names and values are their values)
  * @param boolean $validate whether or not to perform validation on this data. Default is,
  * of course, to validate that data, and set errors on the invalid values. But if the data
  * has already been validated (eg you validated the data then stored it in the DB) you may want
  * to skip this step.
  * @return void
  */
 public function receive_form_submission($req_data = NULL, $validate = TRUE)
 {
     parent::receive_form_submission($req_data, $validate);
     //create or set the model object, if it isn't already
     if (!$this->_model_object) {
         //check to see if the form indicates a PK, in which case we want to only retrieve it and update it
         $pk_name = $this->_model->primary_key_name();
         $model_obj = $this->_model->get_one_by_ID($this->get_input_value($pk_name));
         if ($model_obj) {
             $this->_model_object = $model_obj;
         } else {
             $this->_model_object = EE_Registry::instance()->load_class($this->_model->get_this_model_name());
         }
     }
     //ok so the model object is set. Just set it with the submitted form data (don't save yet though)
     foreach ($this->inputs_values_corresponding_to_model_fields() as $field_name => $field_value) {
         //only set the non-primary key
         if ($field_name != $this->_model->primary_key_name()) {
             $this->_model_object->set($field_name, $field_value);
         }
     }
 }
コード例 #21
0
 /**
  *
  * @param EE_Payment_Method $payment_method
  * @param array $options_array @see EE_Form_Section_Proper::__construct()
  */
 public function __construct(EE_Payment_Method $payment_method, $options_array = array())
 {
     $this->_pm_instance = $payment_method;
     $this->_layout_strategy = new EE_Div_Per_Section_Layout();
     parent::__construct($options_array);
 }
コード例 #22
0
 /**
  * Lays out a row for the subsection
  * @param EE_Form_Section_Proper $form_section
  * @return string
  */
 public function layout_subsection($form_section)
 {
     //		d( $form_section );
     return EEH_HTML::nl(1) . $form_section->get_html() . EEH_HTML::nl(-1);
 }
コード例 #23
0
 /**
  * @return string
  */
 public function display_reg_form()
 {
     $html = '';
     if ($this->reg_form instanceof EE_Form_Section_Proper) {
         $html .= !$this->checkout->admin_request ? $this->reg_form->form_open($this->reg_step_url()) : '';
         if (EE_Registry::instance()->REQ->ajax) {
             $this->reg_form->localize_validation_rules();
             $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
             $html .= $this->reg_form->get_html();
         } else {
             $html .= $this->reg_form->get_html_and_js();
         }
         $html .= !$this->checkout->admin_request ? $this->reg_step_submit_button() : '';
         $html .= !$this->checkout->admin_request ? $this->reg_form->form_close() : '';
     }
     return $html;
 }
 /**
  * switch_payment_method
  *
  * @access public
  * @return string
  */
 public function switch_payment_method()
 {
     if (!$this->_verify_payment_method_is_set()) {
         return FALSE;
     }
     if (apply_filters('FHEE__EE_SPCO_Reg_Step_Payment_Options__registration_checkout__selected_payment_method__display_success', false)) {
         EE_Error::add_success(apply_filters('FHEE__Single_Page_Checkout__registration_checkout__selected_payment_method', sprintf(__('You have selected "%s" as your method of payment. Please note the important payment information below.', 'event_espresso'), $this->checkout->payment_method->name())));
     }
     // generate billing form for selected method of payment if it hasn't been done already
     if ($this->checkout->payment_method->type_obj()->has_billing_form()) {
         $this->checkout->billing_form = $this->_get_billing_form_for_payment_method($this->checkout->payment_method);
     }
     // fill form with attendee info if applicable
     if ($this->checkout->billing_form instanceof EE_Billing_Attendee_Info_Form && $this->checkout->transaction_has_primary_registrant()) {
         $this->checkout->billing_form->populate_from_attendee($this->checkout->transaction->primary_registration()->attendee());
     }
     // and debug content
     if ($this->checkout->billing_form instanceof EE_Billing_Info_Form && $this->checkout->payment_method->type_obj() instanceof EE_PMT_Base) {
         $this->checkout->billing_form = $this->checkout->payment_method->type_obj()->apply_billing_form_debug_settings($this->checkout->billing_form);
     }
     // get html and validation rules for form
     if ($this->checkout->billing_form instanceof EE_Form_Section_Proper) {
         $this->checkout->json_response->set_return_data(array('payment_method_info' => $this->checkout->billing_form->get_html()));
         // localize validation rules for main form
         $this->checkout->billing_form->localize_validation_rules(TRUE);
         $this->checkout->json_response->add_validation_rules(EE_Form_Section_Proper::js_localization());
     } else {
         $this->checkout->json_response->set_return_data(array('payment_method_info' => ''));
     }
     //prevents advancement to next step
     $this->checkout->continue_reg = FALSE;
     return TRUE;
 }
コード例 #25
0
 public static function display_add_new_state_micro_form(EE_Form_Section_Proper $question_group_reg_form)
 {
     // only add the 'new_state_micro_form' when displaying reg forms,
     // not during processing since we process the 'new_state_micro_form' in it's own AJAX request
     $action = EE_Registry::instance()->REQ->get('action', '');
     if ($action === 'process_reg_step' || $action === 'update_reg_step') {
         return $question_group_reg_form;
     }
     // is the "state" question in this form section?
     $input = $question_group_reg_form->get_subsection('state');
     // we're only doing this for state select inputs
     if ($input instanceof EE_State_Select_Input) {
         // load helpers
         EE_Registry::instance()->load_helper('HTML');
         // grab any set values from the request
         $country_name = str_replace('state', 'new_state_country', $input->html_name());
         $state_name = str_replace('state', 'new_state_name', $input->html_name());
         $abbrv_name = str_replace('state', 'new_state_abbrv', $input->html_name());
         $new_state_submit_id = str_replace('state', 'new_state', $input->html_id());
         $country_options = array();
         $countries = EEM_Country::instance()->get_all_countries();
         if (!empty($countries)) {
             foreach ($countries as $country) {
                 if ($country instanceof EE_Country) {
                     $country_options[$country->ID()] = $country->name();
                 }
             }
         }
         $new_state_micro_form = new EE_Form_Section_Proper(array('name' => 'new_state_micro_form', 'html_id' => 'new_state_micro_form', 'layout_strategy' => new EE_No_Layout(), 'subsections' => array('add_new_state' => new EE_Hidden_Input(array('html_name' => str_replace('state', 'add_new_state', $input->html_name()), 'html_id' => str_replace('state', 'add_new_state', $input->html_id()), 'default' => 0)), 'click_here_link' => new EE_Form_Section_HTML(apply_filters('FHEE__EED_Add_New_State__display_add_new_state_micro_form__click_here_link', EEH_HTML::link('', __('click here to add a new state/province', 'event_espresso'), '', 'display-' . $input->html_id(), 'ee-form-add-new-state-lnk display-the-hidden smaller-text hide-if-no-js', '', 'rel="' . $input->html_id() . '"'))), 'add_new_state_micro_form' => new EE_Form_Section_HTML(apply_filters('FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_micro_form', EEH_HTML::div('', $input->html_id() . '-dv', 'ee-form-add-new-state-dv', 'display: none;') . EEH_HTML::h6(__('If your State/Province does not appear in the list above, you can easily add it by doing the following:', 'event_espresso')) . EEH_HTML::ul() . EEH_HTML::li(__('first select the Country that your State/Province belongs to', 'event_espresso')) . EEH_HTML::li(__('enter the name of your State/Province', 'event_espresso')) . EEH_HTML::li(__('enter a two to six letter abbreviation for the name of your State/Province', 'event_espresso')) . EEH_HTML::li(__('click the ADD button', 'event_espresso')) . EEH_HTML::ulx())), 'new_state_country' => new EE_Country_Select_Input($country_options, array('html_name' => $country_name, 'html_id' => str_replace('state', 'new_state_country', $input->html_id()), 'html_class' => $input->html_class() . ' new-state-country', 'html_label_text' => __('New State/Province Country', 'event_espresso'), 'default' => EE_Registry::instance()->REQ->get($country_name, ''), 'required' => false)), 'new_state_name' => new EE_Text_Input(array('html_name' => $state_name, 'html_id' => str_replace('state', 'new_state_name', $input->html_id()), 'html_class' => $input->html_class() . ' new-state-state', 'html_label_text' => __('New State/Province Name', 'event_espresso'), 'default' => EE_Registry::instance()->REQ->get($state_name, ''), 'required' => false)), 'spacer' => new EE_Form_Section_HTML(EEH_HTML::br()), 'new_state_abbrv' => new EE_Text_Input(array('html_name' => $abbrv_name, 'html_id' => str_replace('state', 'new_state_abbrv', $input->html_id()), 'html_class' => $input->html_class() . ' new-state-abbrv', 'html_label_text' => __('New State/Province Abbreviation', 'event_espresso'), 'html_other_attributes' => 'size="24"', 'default' => EE_Registry::instance()->REQ->get($abbrv_name, ''), 'required' => false)), 'add_new_state_submit_button' => new EE_Form_Section_HTML(apply_filters('FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_submit_button', EEH_HTML::nbsp(3) . EEH_HTML::link('', __('ADD', 'event_espresso'), '', 'submit-' . $new_state_submit_id, 'ee-form-add-new-state-submit button button-secondary', '', 'rel="' . $new_state_submit_id . '"'))), 'add_new_state_extra' => new EE_Form_Section_HTML(apply_filters('FHEE__EED_Add_New_State__display_add_new_state_micro_form__add_new_state_extra', EEH_HTML::br(2) . EEH_HTML::div('', '', 'small-text') . EEH_HTML::strong(__('Don\'t know your State/Province Abbreviation?', 'event_espresso')) . EEH_HTML::br() . sprintf(__('You can look here: %s, for a list of Countries and links to their State/Province Abbreviations ("Subdivisions assigned codes" column).', 'event_espresso'), EEH_HTML::link('http://en.wikipedia.org/wiki/ISO_3166-2', 'http://en.wikipedia.org/wiki/ISO_3166-2', '', '', 'ee-form-add-new-state-wiki-lnk')) . EEH_HTML::divx() . EEH_HTML::br() . EEH_HTML::link('', __('cancel new state/province', 'event_espresso'), '', 'hide-' . $input->html_id(), 'ee-form-cancel-new-state-lnk smaller-text', '', 'rel="' . $input->html_id() . '"') . EEH_HTML::divx() . EEH_HTML::br())))));
         $question_group_reg_form->add_subsections(array('new_state_micro_form' => $new_state_micro_form), 'state', false);
     }
     return $question_group_reg_form;
 }
 /**
  * Tests the form was submitted functionality.
  *
  * @group 7431
  */
 public function test_form_was_submitted()
 {
     $form = new EE_Form_Section_Proper(array('name' => 'test_form', 'html_id' => 'test_form', 'subsections' => array('yes_no' => new EE_Yes_No_Input(array('html_label_text' => 'testing', 'default' => false)))));
     $post_data = array('test_form' => array('yes_no' => '0'));
     $this->assertTrue($form->was_submitted($post_data));
 }
コード例 #27
0
 /**
  *    _add_promotions_form_inputs
  *
  * @access    	private
  * @param 	EE_Form_Section_Proper $before_payment_options
  * @return    	EE_Form_Section_Proper
  */
 private function _add_promotions_form_inputs($before_payment_options)
 {
     add_action('wp_enqueue_scripts', array($this, 'enqueue_scripts'));
     EE_Registry::instance()->load_helper('HTML');
     $before_payment_options->add_subsections(array('promotions_form' => new EE_Form_Section_Proper(array('layout_strategy' => new EE_No_Layout(), 'subsections' => array('ee_promotion_code_input' => new EE_Text_Input(array('default' => '', 'html_id' => 'ee-promotion-code-input', 'html_class' => 'ee-promotion-code-input ee-reg-qstn', 'html_name' => 'ee_promotion_code_input', 'html_label_text' => apply_filters('FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_input__html_label_text', EEH_HTML::h4($this->_config->label->singular)))), 'ee_promotion_code_submit' => new EE_Submit_Input(array('html_id' => 'ee-promotion-code', 'html_name' => 'ee_promotion_code_submit', 'default' => apply_filters('FHEE__EED_Promotions___add_promotions_form_inputs__ee_promotion_code_submit__default', sprintf(__('Submit %s', 'event_espresso'), $this->_config->label->singular)))), 'ee_promotion_code_header' => new EE_Form_Section_HTML(EEH_HTML::div(' ', '', 'clear-float')))))));
     return $before_payment_options;
 }