コード例 #1
0
/**
 * Show the export course page.
 */
function WPCW_showPage_ImportExport_export()
{
    $page = new PageBuilder(true);
    $page->showPageHeader(__('Export Training Course', 'wp_courseware'), '75%', WPCW_icon_getPageIconURL());
    // Show form of courses that can be exported.
    $form = new FormBuilder('wpcw_export');
    $form->setSubmitLabel(__('Export Course', 'wp_courseware'));
    // Course selection
    $formElem = new FormElement('export_course_id', __('Course to Export', 'wp_courseware'), true);
    $formElem->setTypeAsComboBox(WPCW_courses_getCourseList(__('--- Select a course to export ---', 'wp_courseware')));
    $form->addFormElement($formElem);
    // Options for what to export
    $formElem = new FormElement('what_to_export', __('What to Export', 'wp_courseware'), true);
    $formElem->setTypeAsRadioButtons(array('whole_course' => __('<b>All</b> - The whole course - including modules, units and quizzes.', 'wp_courseware'), 'just_course' => __('<b>Just the Course</b> - Just the course title, description and settings (no modules, units or quizzes).', 'wp_courseware'), 'course_modules' => __('<b>Course and Modules</b> - Just the course settings and module settings (no units or quizzes).', 'wp_courseware'), 'course_modules_and_units' => __('<b>Course, Modules and Units</b> - The course settings and module settings and units (no quizzes).', 'wp_courseware')));
    $form->addFormElement($formElem);
    $form->setDefaultValues(array('what_to_export' => 'whole_course'));
    if ($form->formSubmitted()) {
        // Do the full export
        if ($form->formValid()) {
            // If data is valid, export will be handled by export class.
        } else {
            $page->showListOfErrors($form->getListOfErrors(), __('Sorry, but unfortunately there were some errors. Please fix the errors and try again.', 'wp_courseware'));
        }
    }
    // Show selection menu for import/export to save pages
    WPCW_showPage_ImportExport_menu('export');
    printf('<p class="wpcw_doc_quick">');
    _e('When you export a course, you\'ll get an <b>XML file</b>, which you can then <b>import into another WordPress website</b> that\'s running <b>WP Courseware</b>.<br/> 
	    When you export the course units with a course, just the <b>HTML to render images and video</b> will be copied, but the <b>actual images and video files will not be exported</b>.', 'wp_courseware');
    printf('</p>');
    echo $form->toString();
    $page->showPageFooter();
}
コード例 #2
0
ファイル: utils_easyform.inc.php プロジェクト: NClaus/Ambrose
 /**
  * Convert an array of details into a form element.
  * @param String $fieldName The name of the form element
  * @param Array $fieldDetails The list of details for the form element.
  */
 protected function createElementObject($fieldName, $fieldDetails)
 {
     // Extract fields
     $label = $this->formObj->getArrayValue($fieldDetails, 'label');
     $type = $this->formObj->getArrayValue($fieldDetails, 'type');
     // Required 'true' or true are valid
     $required = $this->formObj->getArrayValue($fieldDetails, 'required');
     $required = $required == 'true' || $required == '1';
     // Start creating form element if anything other than a break.
     $elem = false;
     if ($type != 'break') {
         $elem = new FormElement($fieldName, $label, $required);
     }
     // Handle specific types
     switch ($type) {
         // Text Area
         case 'textarea':
             $rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
             if ($rows == 0) {
                 $rows = 5;
             }
             $elem->setTypeAsTextArea($rows, 70);
             break;
             // Select/Dropdown
         // Select/Dropdown
         case 'select':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsComboBox($options);
             break;
             // Radio Buttons
         // Radio Buttons
         case 'radio':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsRadioButtons($options);
             break;
             // Checkbox
         // Checkbox
         case 'checkbox':
             $label = false;
             if (isset($fieldDetails['extralabel'])) {
                 $label = $fieldDetails['extralabel'];
             }
             $elem->setTypeAsCheckbox($label);
             break;
             // Checkbox List
         // Checkbox List
         case 'checkboxlist':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsCheckboxList($options);
             break;
             // Merged Fields - process each sub element
         // Merged Fields - process each sub element
         case 'merge':
             $elementList = array();
             if (!empty($fieldDetails['merge'])) {
                 foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
                     $elementList[] = $this->createElementObject($fieldName, $fieldDetails);
                 }
             }
             $elem->setTypeAsMergedElements($elementList);
             break;
             // File upload
         // File upload
         case 'uploadfile':
             $elem->setTypeAsUploadFile($this->formObj->getArrayValue($fieldDetails, 'show_existing'), $this->formObj->getArrayValue($fieldDetails, 'valid_if_value'));
             break;
             // Custom HTML
         // Custom HTML
         case 'custom':
             $elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Hidden field
         // Hidden field
         case 'hidden':
             $elem->setTypeAsHidden();
             break;
             // Section break
         // Section break
         case 'break':
             $this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Text box
         // Text box
         default:
             break;
     }
     // Add optional fields
     if ($type != 'break') {
         // Element description
         if ($desc = $this->formObj->getArrayValue($fieldDetails, 'desc')) {
             $elem->description = $desc;
         }
         // Extra CSS
         if ($cssclass = $this->formObj->getArrayValue($fieldDetails, 'cssclass')) {
             $elem->cssclass = $cssclass;
         }
         // Add extra HTML if provided.
         $extraHTML = $this->formObj->getArrayValue($fieldDetails, 'extrahtml');
         if ($extraHTML) {
             $elem->afterFormElementHTML = $extraHTML;
         }
         // Add custom error message if there is one
         $elem->errorMessage = $this->formObj->getArrayValue($fieldDetails, 'errormsg');
         // Validation rules
         if (isset($fieldDetails['validate']) && is_array($fieldDetails['validate'])) {
             // Is it a custom function? If so, get the function name.
             if ($this->formObj->getArrayValue($fieldDetails['validate'], 'type') == 'function') {
                 $elem->validationFn = $this->formObj->getArrayValue($fieldDetails['validate'], 'fname');
                 $elem->errorMessage = $this->formObj->getArrayValue($fieldDetails['validate'], 'error');
             } else {
                 $elem->setValidationRules($fieldDetails['validate']);
             }
         }
         // See if there are any suffix items? If so, parse them.
         // See wiki for documentation on how to structure this.
         if (!empty($fieldDetails['suffix_subitems'])) {
             $suffixItems = array();
             // suffix_subitems contains a list of 'position' => array(fieldName => fieldDetails)
             foreach ($fieldDetails['suffix_subitems'] as $position => $elementDetails) {
                 $suffixItems[$position] = array();
                 // Need to process each field now we know the position.
                 foreach ($elementDetails as $fieldName => $fieldDetails) {
                     // Add the position of this item (in order), with the object for this element.
                     $suffixItems[$position][] = $this->createElementObject($fieldName, $fieldDetails);
                 }
             }
             // Update the form element with the subitems
             $elem->setSuffixItems($suffixItems);
         }
     }
     return $elem;
 }
コード例 #3
0
ファイル: wp-portfolio.php プロジェクト: hscale/webento
/**
 * Shows the page that allows the details of a website to be modified or added to the portfolio.
 */
function WPPortfolio_modify_website()
{
    // Determine if we're in edit mode. Ensure we get correct mode regardless of where it is.
    $editmode = false;
    if (isset($_POST['editmode'])) {
        $editmode = $_POST['editmode'] == 'edit';
    } else {
        if (isset($_GET['editmode'])) {
            $editmode = $_GET['editmode'] == 'edit';
        }
    }
    // Get the site ID. Ensure we get ID regardless of where it is.
    $siteid = 0;
    if (isset($_POST['website_siteid'])) {
        $siteid = is_numeric($_POST['website_siteid']) ? $_POST['website_siteid'] + 0 : 0;
    } else {
        if (isset($_GET['siteid'])) {
            $siteid = is_numeric($_GET['siteid']) ? $_GET['siteid'] + 0 : 0;
        }
    }
    // Work out page heading
    $verb = __("Add New", 'wp-portfolio');
    if ($editmode) {
        $verb = __("Modify", 'wp-portfolio');
    }
    ?>
	<div class="wrap">
	<div id="icon-themes" class="icon32">
	<br/>
	</div>
	<h2><?php 
    echo $verb . ' ' . __('Website Details', 'wp-portfolio');
    ?>
</h2>	
	<?php 
    // Check id is a valid number if editing $editmode
    if ($editmode && $siteid == 0) {
        WPPortfolio_showMessage(sprintf(__('Sorry, but no website with that ID could be found. Please click <a href="%s">here</a> to return to the list of websites.', 'wp-portfolio'), WPP_WEBSITE_SUMMARY), true);
        return;
    }
    // If we're editing, try to get the website details.
    if ($editmode && $siteid > 0) {
        // Get details from the database
        $websitedetails = WPPortfolio_getWebsiteDetails($siteid);
        // False alarm, couldn't find it.
        if (count($websitedetails) == 0) {
            $editmode = false;
        }
    } else {
        $websitedetails['siteactive'] = 1;
        $websitedetails['displaylink'] = 1;
    }
    // Check if website is being added, if so, add to the database.
    if (isset($_POST) && isset($_POST['update'])) {
        // Grab specified details
        $data = array();
        $data['siteid'] = $_POST['website_siteid'];
        $data['sitename'] = trim(strip_tags($_POST['website_sitename']));
        $data['siteurl'] = trim(strip_tags($_POST['website_siteurl']));
        $data['sitedescription'] = $_POST['website_sitedescription'];
        $data['sitegroup'] = $_POST['website_sitegroup'];
        $data['customthumb'] = trim(strip_tags($_POST['website_customthumb']));
        $data['siteactive'] = trim(strip_tags($_POST['website_siteactive']));
        $data['displaylink'] = trim(strip_tags($_POST['website_displaylink']));
        $data['siteorder'] = trim(strip_tags($_POST['website_siteorder'])) + 0;
        $data['specificpage'] = trim(strip_tags($_POST['website_specificpage']));
        $data['customfield'] = trim(strip_tags($_POST['website_customfield']));
        $data['siteadded'] = trim(strip_tags($_POST['siteadded']));
        // Keep track of errors for validation
        $errors = array();
        // Ensure all fields have been completed
        if (!($data['sitename'] && $data['siteurl'] && $data['sitedescription'])) {
            array_push($errors, __("Please check that you have completed the site name, url and description fields.", 'wp-portfolio'));
        }
        // Check custom field length
        if (strlen($data['customfield']) > 255) {
            array_push($errors, __("Sorry, but the custom field is limited to a maximum of 255 characters.", 'wp-portfolio'));
        }
        // Check that the date is correct
        if ($data['siteadded']) {
            $dateTS = 0;
            //strtotime($data['siteadded']);
            if (preg_match('/^([0-9]{4}\\-[0-9]{2}\\-[0-9]{2} [0-9]{2}\\:[0-9]{2}\\:[0-9]{2})$/', $data['siteadded'], $matches)) {
                $dateTS = strtotime($data['siteadded']);
            }
            // Invalid date
            if ($dateTS == 0) {
                array_push($errors, __("Sorry, but the 'Date Added' date format was not recognised. Please enter a date in the format <em>'yyyy-mm-dd hh:mm:ss'</em>.", 'wp-portfolio'));
            } else {
                $data['siteadded'] = date('Y-m-d H:i:s', $dateTS);
            }
        } else {
            // Date is blank, so create correct one.
            $data['siteadded'] = date('Y-m-d H:i:s');
        }
        // Continue if there are no errors
        if (count($errors) == 0) {
            global $wpdb;
            $table_name = $wpdb->prefix . TABLE_WEBSITES;
            // Change query based on add or edit
            if ($editmode) {
                $query = arrayToSQLUpdate($table_name, $data, 'siteid');
            } else {
                unset($data['siteid']);
                // Don't need id for an insert
                $data['siteadded'] = date('Y-m-d H:i:s');
                // Only used if adding a website.
                $query = arrayToSQLInsert($table_name, $data);
            }
            // Try to put the data into the database
            $wpdb->show_errors();
            $wpdb->query($query);
            // When adding, clean fields so that we don't show them again.
            if ($editmode) {
                WPPortfolio_showMessage(__("Website details successfully updated.", 'wp-portfolio'));
                // Retrieve the details from the database again
                $websitedetails = WPPortfolio_getWebsiteDetails($siteid);
            } else {
                WPPortfolio_showMessage(__("Website details successfully added.", 'wp-portfolio'));
                $data['siteid'] = false;
                $data['sitename'] = false;
                $data['siteurl'] = false;
                $data['sitedescription'] = false;
                $data['sitegroup'] = false;
                $data['customthumb'] = false;
                $data['siteactive'] = 1;
                // The default is that the website is visible.
                $data['displaylink'] = 1;
                // The default is to show the link.
                $data['siteorder'] = 0;
                $data['specificpage'] = 0;
                $data['customfield'] = false;
            }
        } else {
            $message = __("Sorry, but unfortunately there were some errors. Please fix the errors and try again.", 'wp-portfolio') . '<br><br>';
            $message .= "<ul style=\"margin-left: 20px; list-style-type: square;\">";
            // Loop through all errors in the $error list
            foreach ($errors as $errormsg) {
                $message .= "<li>{$errormsg}</li>";
            }
            $message .= "</ul>";
            WPPortfolio_showMessage($message, true);
            $websitedetails = $data;
        }
    }
    $form = new FormBuilder();
    $formElem = new FormElement("website_sitename", __("Website Name", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitename');
    $formElem->description = __("The proper name of the website.", 'wp-portfolio') . ' <em>' . __('(Required)', 'wp-portfolio') . '</em>';
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_siteurl", __("Website URL", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteurl');
    $formElem->description = __("The URL for the website, including the leading", 'wp-portfolio') . ' <em>http://</em>. <em>' . __('(Required)', 'wp-portfolio') . '</em>';
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_sitedescription", __("Website Description", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitedescription');
    $formElem->description = __("The description of your website. HTML is permitted.", 'wp-portfolio') . ' <em>' . __('(Required)', 'wp-portfolio') . "</em>";
    $formElem->setTypeAsTextArea(4, 70);
    $form->addFormElement($formElem);
    global $wpdb;
    $table_name = $wpdb->prefix . TABLE_WEBSITE_GROUPS;
    $SQL = "SELECT * FROM {$table_name} ORDER BY groupname";
    $groups = $wpdb->get_results($SQL, OBJECT);
    $grouplist = array();
    foreach ($groups as $group) {
        $grouplist[$group->groupid] = stripslashes($group->groupname);
    }
    $formElem = new FormElement("website_sitegroup", "Website Group");
    $formElem->setTypeAsComboBox($grouplist);
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'sitegroup');
    $formElem->description = __("The group you want to assign this website to.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $form->addBreak('advanced-options', '<div id="wpp-hide-show-advanced" class="wpp_hide"><a href="#">' . __('Show Advanced Settings', 'wp-portfolio') . '</a></div>');
    $formElem = new FormElement("website_siteactive", __("Show Website?", 'wp-portfolio'));
    $formElem->setTypeAsComboBox(array('1' => __('Show Website', 'wp-portfolio'), '0' => __('Hide Website', 'wp-portfolio')));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteactive');
    $formElem->description = __("By changing this option, you can show or hide a website from the portfolio.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_displaylink", __("Show Link?", 'wp-portfolio'));
    $formElem->setTypeAsComboBox(array('show_link' => __('Show Link', 'wp-portfolio'), 'hide_link' => __('Hide Link', 'wp-portfolio')));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'displaylink');
    $formElem->description = __("With this option, you can choose whether or not to display the URL to the website.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("siteadded", __("Date Website Added", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteadded');
    $formElem->description = __("Here you can adjust the date in which the website was added to the portfolio. This is useful if you're adding items retrospectively. (valid format is yyyy-mm-dd hh:mm:ss)", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_siteorder", __("Website Ordering", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteorder');
    $formElem->description = '&bull; ' . __("The number to use for ordering the websites. Websites are rendered in ascending order, first by this order value (lowest value first), then by website name.", 'wp-portfolio') . '<br/>' . '&bull; ' . __("e.g. Websites (A, B, C, D) with ordering (50, 100, 0, 50) will be rendered as (C, A, D, B).", 'wp-portfolio') . '<br/>' . '&bull; ' . __("If all websites have 0 for ordering, then the websites are rendered in alphabetical order by name.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_customthumb", __("Custom Thumbnail URL", 'wp-portfolio'));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'customthumb');
    $formElem->cssclass = "long-text";
    $formElem->description = __("If specified, the URL of a custom thumbnail to use <em>instead</em> of the screenshot of the URL above.", 'wp-portfolio') . '<br/>' . '&bull; ' . __("The image URL must include the leading <em>http://</em>, e.g.", 'wp-portfolio') . ' <em>http://www.yoursite.com/wp-content/uploads/yourfile.jpg</em><br/>' . '&bull; ' . __("Leave this field blank to use an automatically generated screenshot of the website specified above.", 'wp-portfolio') . '<br/>' . '&bull; ' . __("Custom thumbnails are automatically resized to match the size of the other thumbnails.", 'wp-portfolio');
    $form->addFormElement($formElem);
    $formElem = new FormElement("website_customfield", __("Custom Field", 'wp-portfolio') . "<br/><span class=\"wpp-advanced-feature\">&bull; " . __("Advanced Feature", 'wp-portfolio') . "</span>");
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'customfield');
    $formElem->cssclass = "long-text";
    $formElem->description = sprintf(__("Allows you to specify a value that is substituted into the <code><b>%s</b></code> field. This can be any value. Examples of what you could use the custom field for include:", 'wp-portfolio'), WPP_STR_WEBSITE_CUSTOM_FIELD) . '<br/>' . '&bull; ' . __("Affiliate URLs for the actual URL that visitors click on.", 'wp-portfolio') . '<br/>' . '&bull; ' . __("Information as to the type of work a website relates to (e.g. design work, SEO, web development).", 'wp-portfolio');
    $form->addFormElement($formElem);
    // Advanced Features
    $formElem = new FormElement("website_specificpage", __("Use Specific Page Capture", 'wp-portfolio') . "<br/>" . "<span class=\"wpp-advanced-feature\">&bull; " . __("Advanced Feature", 'wp-portfolio') . "</span><br/>" . "<span class=\"wpp-stw-paid\">&bull; " . __("STW Paid Account Only", 'wp-portfolio') . "</span>");
    $formElem->setTypeAsComboBox(array('0' => __('No - Homepage Only', 'wp-portfolio'), '1' => __('Yes - Show Specific Page', 'wp-portfolio')));
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'specificpage');
    $formElem->description = '&bull; <b>' . __("Requires Shrink The Web 'Specific Page Capture' Paid (Basic or Plus) feature.", 'wp-portfolio') . '</b><br/>' . '&bull; ' . __("If enabled show internal web page rather than website's homepage. If in doubt, select <b>'No - Homepage Only'</b>.", 'wp-portfolio');
    $form->addFormElement($formElem);
    // Hidden Elements
    $formElem = new FormElement("website_siteid", false);
    $formElem->value = WPPortfolio_getArrayValue($websitedetails, 'siteid');
    $formElem->setTypeAsHidden();
    $form->addFormElement($formElem);
    $formElem = new FormElement("editmode", false);
    $formElem->value = $editmode ? "edit" : "add";
    $formElem->setTypeAsHidden();
    $form->addFormElement($formElem);
    $form->setSubmitLabel(($editmode ? __("Update", 'wp-portfolio') : __("Add", 'wp-portfolio')) . " " . __("Website Details", 'wp-portfolio'));
    echo $form->toString();
    ?>
	
	<br><br>
	</div><!-- wrap -->
	<?php 
}
コード例 #4
0
ファイル: utils_easyform.inc.php プロジェクト: nerdhaus/avse
 /**
  * Convert an array of details into a form element.
  * @param String $fieldName The name of the form element
  * @param Array $fieldDetails The list of details for the form element.
  */
 protected function createElementObject($fieldName, $fieldDetails)
 {
     // Extract fields
     $label = $this->formObj->getArrayValue($fieldDetails, 'label');
     $type = $this->formObj->getArrayValue($fieldDetails, 'type');
     // Required 'true' or true are valid
     $required = $this->formObj->getArrayValue($fieldDetails, 'required');
     $required = $required == 'true' || $required == '1';
     // Start creating form element if anything other than a break.
     $elem = false;
     if ($type != 'break') {
         $elem = new FormElement($fieldName, $label, $required);
     }
     // Handle specific types
     switch ($type) {
         // Text Area
         case 'textarea':
             $rows = $this->formObj->getArrayValue($fieldDetails, 'rows') + 0;
             if ($rows == 0) {
                 $rows = 5;
             }
             $elem->setTypeAsTextArea($rows, 70);
             break;
             // Select/Dropdown
         // Select/Dropdown
         case 'select':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsComboBox($options);
             break;
             // Radio Buttons
         // Radio Buttons
         case 'radio':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsRadioButtons($options);
             break;
             // Checkbox
         // Checkbox
         case 'checkbox':
             $label = false;
             if (isset($fieldDetails['extralabel'])) {
                 $label = $fieldDetails['extralabel'];
             }
             $elem->setTypeAsCheckbox($label);
             break;
             // Checkbox List
         // Checkbox List
         case 'checkboxlist':
             $options = false;
             if (isset($fieldDetails['data']) && is_array($fieldDetails['data'])) {
                 $options = $fieldDetails['data'];
             }
             $elem->setTypeAsCheckboxList($options);
             break;
             // Merged Fields - process each sub element
         // Merged Fields - process each sub element
         case 'merge':
             $elementList = array();
             if (!empty($fieldDetails['merge'])) {
                 foreach ($fieldDetails['merge'] as $fieldName => $fieldDetails) {
                     $elementList[] = $this->createElementObject($fieldName, $fieldDetails);
                 }
             }
             $elem->setTypeAsMergedElements($elementList);
             break;
             // Custom HTML
         // Custom HTML
         case 'custom':
             $elem->setTypeAsCustom($this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Hidden field
         // Hidden field
         case 'hidden':
             $elem->setTypeAsHidden();
             break;
             // Section break
         // Section break
         case 'break':
             $this->formObj->addBreak($fieldName, $this->formObj->getArrayValue($fieldDetails, 'html'));
             break;
             // Text box
         // Text box
         default:
             break;
     }
     // Add optional fields
     if ($type != 'break') {
         // Element description
         if ($desc = $this->formObj->getArrayValue($fieldDetails, 'desc')) {
             $elem->description = $desc;
         }
         // Extra CSS
         if ($cssclass = $this->formObj->getArrayValue($fieldDetails, 'cssclass')) {
             $elem->cssclass = $cssclass;
         }
         // Add extra HTML if provided.
         $extraHTML = $this->formObj->getArrayValue($fieldDetails, 'extrahtml');
         if ($extraHTML) {
             $elem->afterFormElementHTML = $extraHTML;
         }
         // Validation rules
         if (isset($fieldDetails['validate']) && is_array($fieldDetails['validate'])) {
             // Is it a custom function? If so, get the function name.
             if ($this->formObj->getArrayValue($fieldDetails['validate'], 'type') == 'function') {
                 $elem->validationFn = $this->formObj->getArrayValue($fieldDetails['validate'], 'fname');
                 $elem->errorMessage = $this->formObj->getArrayValue($fieldDetails['validate'], 'error');
             } else {
                 $elem->setValidationRules($fieldDetails['validate']);
             }
         }
     }
     return $elem;
 }