/** * * @param array $options_array keys: { * @type EEM_Base $model * @type EE_Base_Class $model_object * @type array $subsection_args array keys should be subsection names (that either do or will exist), and values are the arrays as you would pass them to that subsection * } * @throws EE_Error */ public function __construct($options_array = array()) { if (isset($options_array['model']) && $options_array['model'] instanceof EEM_Base) { $this->_model = $options_array['model']; } if (!$this->_model || !$this->_model instanceof EEM_Base) { throw new EE_Error(sprintf(__("Model Form Sections must first specify the _model property to be a subclass of EEM_Base", "event_espresso"))); } if (isset($options_array['subsection_args'])) { $subsection_args = $options_array['subsection_args']; } else { $subsection_args = array(); } //gather fields and relations to convert to inputs //but if they're just going to exclude a field anyways, don't bother converting it to an input $exclude = $this->_subsections; if (isset($options_array['exclude'])) { $exclude = array_merge($exclude, array_flip($options_array['exclude'])); } $model_fields = array_diff_key($this->_model->field_settings(), $exclude); $model_relations = array_diff_key($this->_model->relation_settings(), $exclude); //convert fields and relations to inputs $this->_subsections = array_merge($this->_convert_model_fields_to_inputs($model_fields), $this->_convert_model_relations_to_inputs($model_relations, $subsection_args), $this->_subsections); parent::__construct($options_array); if (isset($options_array['model_object']) && $options_array['model_object'] instanceof EE_Base_Class) { $this->populate_model_obj($options_array['model_object']); } }
/** * * @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); }
/** * * @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); }
function __construct() { $this->_subsections = array('h1' => new EE_Form_Section_HTML('hello wordl'), 'name' => new EE_Text_Input(array('required' => true, 'default' => 'your name here')), 'email' => new EE_Email_Input(array('required' => false)), 'shirt_size' => new EE_Select_Input(array('' => 'Please select...', 's' => __("Small", "event_espresso"), 'm' => __("Medium", "event_espresso"), 'l' => __("Large", "event_espresso")), array('required' => true, 'default' => 's')), 'month_normal' => new EE_Month_Input(), 'month_leading_zero' => new EE_Month_Input(true), 'year_2' => new EE_Year_Input(false, 1, 1), 'year_4' => new EE_Year_Input(true, 0, 10, array('default' => '2017')), 'yes_no' => new EE_Yes_No_Input(array('html_label_text' => __("Yes or No", "event_espresso"))), 'credit_card' => new EE_Credit_Card_Input(), 'image_1' => new EE_Admin_File_Uploader_Input(), 'image_2' => new EE_Admin_File_Uploader_Input(), 'skillz' => new EE_Checkbox_Multi_Input(array('php' => 'PHP', 'mysql' => 'MYSQL'), array('default' => array('php'))), 'float' => new EE_Float_Input(), 'essay' => new EE_Text_Area_Input(), 'amenities' => new EE_Select_Multiple_Input(array('hottub' => 'Hot Tub', 'balcony' => "Balcony", 'skylight' => 'SkyLight', 'no_axe' => 'No Axe Murderers'), array('default' => array('hottub', 'no_axe'))), 'payment_methods' => new EE_Select_Multi_Model_Input(EEM_Payment_Method::instance()->get_all())); $this->_layout_strategy = new EE_Div_Per_Section_Layout(); parent::__construct(); }