public function __construct() { parent::__construct("front-profile-file-manager-uploads"); //set form to submit method $this->setAttribute("method", "post"); $this->add(array("name" => "mode", "type" => "select", "attributes" => array("id" => "mode", "required" => "required", "title" => "Specify which section the file will be uploaded. Options are Images or Documents. Where the file does not fit the section profile, the upload will fail."), "options" => array("label" => "Specify section", "empty_option" => "--select--", "value_options" => array("image" => "Images", "document" => "Documents")))); $this->add(array("name" => "tmp_file", "type" => "file", "attributes" => array("id" => "tmp_file", "title" => "Select file form filesystem", "required" => "required"), "options" => array("label" => "Set file to be upload"))); $this->add(array("name" => "filename", "type" => "text", "attributes" => array("id" => "filename", "title" => "Set the filename the file should be uploaded with. Where none is set, the filename will used as received", "required" => "required"), "options" => array("label" => "Filename"), "filters" => array(), "required" => TRUE, "validators" => array(array('name' => "Regex", 'options' => array('pattern' => "/^[a-zA-Z0-9._]+\$/", 'messages' => array(Regex::NOT_MATCH => "Filename contains illegal characters. Only alpha numeric, underscore and full stop characters are allowed")))))); $this->add(array("name" => "additional_path", "type" => "hidden", "attributes" => array("id" => "additional_path"), "options" => array("label" => "Sub folder"), "filters" => array(), "validators" => array())); $this->add(array("name" => "submit", "type" => "submit", "attributes" => array("value" => "Submit"), "options" => array("ignore" => TRUE))); }
public function __construct($objForm) { parent::__construct('behaviour-form-journey-stop'); $this->setAttribute("method", "post"); //set field elements in correct order $arr_fields = array('fk_journey_id', 'loggedin', 'active', 'event_runtime_trigger', 'behaviour', 'beh_action', 'setup_complete'); foreach ($arr_fields as $field) { $objElement = $objForm->get($field); $objForm->remove($field); $this->add(array('name' => $objElement->getAttribute('name'), 'type' => $objElement->getAttribute('type'), 'attributes' => $objElement->getAttributes(), 'options' => $objElement->getOptions())); } //end foreach $this->add(array('type' => 'submit', 'name' => 'submit', 'attributes' => array('value' => 'Submit'), 'options' => array('value' => 'Submit'))); $this->setJavascript(); }
public function __construct() { parent::__construct("native_profile_settings_form"); //set form submit post method $this->setAttribute("method", "post"); $this->add(array("type" => "text", "name" => "profile_title", "attributes" => array("id" => "profile_title", "required" => "required", "title" => "Set Profile Title. This is displayed in the Browser title bar", "placeholder" => "Profile Title"), "options" => array("label" => "Profile Title"), "filters" => array(array("name" => "StripTags"), array("name" => "StringTrim")), "validators" => array(array("name" => "NotEmpty"), array("name" => "Zend\\I18n\\Validator\\Alpha", "options" => array("allowWhiteSpace" => TRUE)), array("name" => "StringLength", "options" => array("max" => 50))))); $this->add(array("type" => "text", "name" => "profile_icon", "attributes" => array("id" => "profile_icon", "title" => "Set icon url. This appears in the Menu bar", "placeholder" => "Set icon url"), "options" => array("label" => "Profile Icon (Favicon)"))); $this->add(array("type" => "file", "name" => "profile_logo", "attributes" => array("id" => "profile_logo"), "options" => array("label" => "Profile Logo"))); $this->add(array("type" => "checkbox", "name" => "enable_footer", "attributes" => array("id" => "enable_footer"), "options" => array("label" => "Enable Footer", "checked_value" => "1", "unchecked_value" => "0", "use_hidden_value" => TRUE))); $this->add(array("type" => "textarea", "name" => "footer_content", "attributes" => array("id" => "footer_content"), "options" => array("label" => "Footer Content"))); $this->add(array("type" => "text", "name" => "menu_main_relationship", "attributes" => array("id" => "menu_main_relationship", "title" => "Set Relationship Label", "placeholder" => "Relationship"), "options" => array("label" => "Main Menu - Relationship Label"), "filters" => array(array("name" => "StripTags"), array("name" => "StringTrim")))); $this->add(array("type" => "text", "name" => "menu_main_data", "attributes" => array("id" => "menu_main_data", "title" => "Set Data Label", "placeholder" => "Data"), "options" => array("label" => "Main Menu - Data Label"), "filters" => array(array("name" => "StripTags"), array("name" => "StringTrim")))); $this->add(array("type" => "text", "name" => "menu_main_sale", "attributes" => array("id" => "menu_main_sale", "title" => "Set Sale Label", "placeholder" => "Sale"), "options" => array("label" => "Main Menu - Sale Label"), "filters" => array(array("name" => "StripTags"), array("name" => "StringTrim")))); $this->add(array("type" => "text", "name" => "menu_main_administration", "attributes" => array("id" => "menu_main_administration", "title" => "Set Administration Label", "placeholder" => "Administration"), "options" => array("label" => "Main Menu - Administration Label"), "filters" => array(array("name" => "StripTags"), array("name" => "StringTrim")))); $this->add(array("name" => "submit", "type" => "submit", "attributes" => array("value" => "Submit"), "options" => array("ignore" => TRUE))); }
public function __construct() { parent::__construct("user-native-preferences"); //set form to submit method $this->setAttribute("method", "post"); $this->setAttribute("class", "user-native-preferences-form"); $this->add(array("type" => "select", "name" => "cpp_layout_id", "attributes" => array("id" => "cpp_layout_id", "title" => "Set the default My Contacts Page Layout to use when viewing Contacts"), "options" => array("label" => "My Contacts Page - Default Layout", "empty_option" => "--select--", "value_options" => array()), "required" => FALSE, "allow_empty" => TRUE)); $this->add(array("type" => "select", "name" => "cpp_form_id", "attributes" => array("id" => "cpp_form_id", "title" => "Set default Form to use when creating or editing a Contact"), "options" => array("label" => "View / Edit Contact - Default Layout", "empty_option" => "--select--", "value_options" => array()), "required" => FALSE, "allowEmpty" => TRUE)); $this->add(array("type" => "select", "name" => "home_page", "attributes" => array("id" => "home_page", "title" => "This page will be loaded once you logged into the system"), "options" => array("label" => "Default Login Page", "empty_option" => "--select--", "value_options" => array()), "required" => FALSE, "allow_empty" => TRUE)); $this->add(array("type" => "select", "name" => "news_feed_options", "attributes" => array("id" => "news_feed_options", "title" => "Set News Feed Options"), "options" => array("label" => "News Feed Options", "empty_option" => "--select--", "value_options" => array("disabled" => "Disabled", "enabled" => "Enabled")), "required" => FALSE, "allow_empty" => TRUE)); // $this->add(array( // "type" => "select", // "name" => "contacts_toolkit_default_tab", // "attributes" => array( // "id" => "contacts_toolkit_default_tab", // "title" => "Load this tab by default in the Contact Toolkit", // ), // "options" => array( // "label" => "Contact Toolkit - Default Tab", // "empty_option" => "--select--", // "value_options" => array(), // ), // "required" => FALSE, // "allow_empty" => TRUE, // )); // $this->add(array( // "type" => "select", // "name" => "user_toolkit_default_tab", // "attributes" => array( // "id" => "user_toolkit_default_tab", // "title" => "Load this tab by default in the User Toolkit", // ), // "options" => array( // "label" => "User Toolkit - Default Tab", // "empty_option" => "--select--", // "value_options" => array( // "todo" => "To-Do List", // ), // ), // "required" => FALSE, // "allow_empty" => TRUE, // )); $this->add(array("name" => "submit", "attributes" => array("value" => "Login"), "options" => array("ignore" => TRUE))); }
public function __construct($objForm) { parent::__construct('behaviour-form-task'); $this->setAttribute("method", "post"); //set field elements in correct order $arr_fields = array('fk_user_id', 'content', 'generic2', 'generic1', 'email', 'active', 'event_runtime_trigger', 'behaviour', 'beh_action', 'setup_complete'); foreach ($arr_fields as $field) { if (!$objForm->has($field)) { continue; } //end if $objElement = $objForm->get($field); $objForm->remove($field); $this->add(array('name' => $objElement->getAttribute('name'), 'type' => $objElement->getAttribute('type'), 'attributes' => $objElement->getAttributes(), 'options' => $objElement->getOptions())); } //end foreach $this->add(array('type' => 'submit', 'name' => 'submit', 'attributes' => array('value' => 'Submit'), 'options' => array('value' => 'Submit'))); $this->setJavascript(); }
/** * Construct a form based on data received from the API * @param object $objFormData * @return \FrontCore\Forms\FrontCoreSystemFormBase */ protected function constructForm($objFormData) { //convert data to array $arr_form_data = \Zend\Json\Json::decode(\Zend\Json\Json::encode($objFormData), TRUE); //create form object $objForm = new FrontCoreSystemFormBase(); $objForm->setAttribute("id", "form"); $objForm->setAttributes($arr_form_data["attributes"]); $objForm->setOptions($arr_form_data["options"]); //add form elements foreach ($arr_form_data["arr_fields"] as $arr_element) { if ($arr_element["attributes"]["type"] == "") { $arr_element["attributes"]["type"] = "text"; } //end if $arr_element["type"] = $arr_element["attributes"]["type"]; $arr_element["name"] = $arr_element["attributes"]["name"]; if ($arr_element["attributes"]["required"] === TRUE || strtolower($arr_element["attributes"]["required"]) == "true" || strtolower($arr_element["attributes"]["required"]) == "required") { $arr_element["required"] = TRUE; } else { $arr_element["required"] = FALSE; $arr_element["allow_empty"] = TRUE; } //end if $arr_element["validators"] = array(); $arr_element["filters"] = array(); $objForm->add($arr_element); } //end foreach $objForm->get("submit")->setValue("Submit"); return $objForm; }
/** * Build a Zend form object from data received * @param object $objFormData * @param array $arr_form_attributes * @return \Zend\Form\Form */ private function constructForm($objFormData, $arr_form_attributes) { //set some default values if (!isset($arr_form_attributes["name"])) { $arr_form_attributes["name"] = "form"; } //end if //create the form object $objForm = new FrontCoreSystemFormBase($arr_form_attributes["name"]); //check if field groups has been set if (isset($objFormData->arr_field_groups)) { $objForm->setAttribute("arr_field_groups", $objFormData->arr_field_groups); //remove field groups unset($objFormData->arr_field_groups); } //end if foreach ($objFormData as $key => $objElement) { //create the element $element_type = strtolower($objElement->attributes->type); $arr_element = json_decode(json_encode($objElement), true); //refine some information $arr_element["name"] = $arr_element["attributes"]["name"]; unset($arr_element["attributes"]["name"]); $arr_element["type"] = $arr_element["attributes"]["type"]; unset($arr_element["attributes"]["type"]); //set value from default value if (isset($arr_element["attributes"]["default_value"])) { $arr_element["attributes"]["value"] = $arr_element["attributes"]["default_value"]; unset($arr_element["attributes"]["default_value"]); } //end if //apply conditions where required switch (strtolower($arr_element["type"])) { case "submit": $arr_element["attributes"]["value"] = "Submit"; break; case "date": $arr_element["type"] = "text"; break; } //end swtich $objForm->add($arr_element); } //end foreach return $objForm; }