Example #1
0
 /**
  * Purpose: To group related elements in a form with a box.
  * @param type $name - to specify a form name.
  * @param type $options [legend] or [label] - to set the label for the legend.
  * @param type $options [form] - Specifies one or more forms the fieldset belongs to.
  */
 private function alias_frm_start_fieldset($name, $options)
 {
     $legend = isset($options['legend']) ? $options['legend'] : $name;
     $legend = isset($options['label']) ? $options['label'] : $legend;
     $fieldset_options = '';
     if (isset($options['disabled']) && main_fn::get_bool_value($options['disabled']) === true) {
         $fieldset_options .= " disabled";
     }
     $fieldset_options .= isset($options['class']) ? " class=\"{$options['class']}\"" : '';
     $fieldset_options .= isset($options['form']) ? " form=\"{$options['form']}\"" : '';
     $fieldset_options .= !empty($name) ? " name=\"{$name}\"" : '';
     $this->set_html("<fieldset{$fieldset_options}>");
     $this->set_html("<legend>{$legend}</legend>\r\n");
 }
Example #2
0
 /**
  * Purpose: To generate a group of checkboxes.
  * @param type $name - The name for the group of checkboxes.
  * @param $htmlOptions - <options> - Array of checkbox data.
  */
 private function frm_checkboxes($name, $htmlOptions)
 {
     $checkboxes = isset($htmlOptions['options']) ? $htmlOptions['options'] : array();
     $c = count($checkboxes);
     $input_name = $c > 1 ? $name . '[]' : $name;
     foreach ($checkboxes as $value => $label) {
         $selected = array('');
         if (isset($this->model[$name])) {
             if (is_array($this->model[$name])) {
                 $selected = $this->model[$name];
             } elseif (main_fn::is_serialized($this->model[$name]) === true) {
                 $selected = main_fn::safe_unserialize($this->model[$name]);
             } elseif (!empty($this->model[$name])) {
                 $selected = array($this->model[$name]);
             }
         }
         if ($c == 1) {
             $checkit = isset($htmlOptions['checked']) && main_fn::get_bool_value($htmlOptions['checked']) === true ? ' checked="checked"' : '';
         } else {
             $checkit = isset($htmlOptions['checked'][$value]) && main_fn::get_bool_value($htmlOptions['checked'][$value]) === true ? ' checked="checked"' : '';
         }
         $req = $this->get_request($name, $selected, $this->method);
         if (is_array($req)) {
             $select = in_array($value, $req) ? ' checked="checked"' : $checkit;
         } else {
             $select = $value == $req ? ' checked="checked"' : $checkit;
         }
         $this->input('checkbox', $input_name, $value, $label, $select, $htmlOptions);
     }
     // end foreach
     if ($c == '0') {
         $err = "Form Command - checkboxes - Named: {$name} - Missing Options!";
         $this->report_form_error($err);
     }
 }
Example #3
0
 /**
  * Purpose: Helper method for validator - to validate text fields.
  */
 private function validator($command, $name, $options = '')
 {
     // Add required class if required was set.
     if (isset($options['required']) && main_fn::get_bool_value($options['required']) === true) {
         $class = 'required';
     } else {
         $class = '';
     }
     //If nothing to do, exit.
     if (!is_array($options)) {
         $this->do_class_output($class);
         return false;
     }
     // If no validation type, exit;
     if (!isset($options['validator'][0])) {
         $this->do_class_output($class);
         return false;
     }
     // Only validate text, password, and textarea commands.
     if (!($command == 'frm_text' || $command == 'frm_password' || $command == 'frm_textarea')) {
         $this->do_class_output($class);
         return false;
     }
     $type_of_validator = strtolower($options['validator'][0]);
     $class .= $type_of_validator . ' ';
     // Show error if type of validator is not found.
     if (is_array($type_of_validator)) {
         $err = "Form Command - {$command} - Named: {$name} - Missing Validator!";
         $this->report_form_error($err);
         return false;
     }
     // Show error if a valid validator is not found.
     if (!in_array($type_of_validator, $this->get_valid_validators())) {
         $err = "Form Command - {$command} - Named: {$name} - validator {$type_of_validator} Not Found!";
         $this->report_form_error($err);
         return false;
     }
     // If validator has an array, do validator helper on that array only.
     if (isset($options['validator'][1]) && is_array($options['validator'][1])) {
         $val_options = $options['validator'][1];
         $class .= $this->validator_helper($command, $name, $val_options);
     }
     $this->do_class_output($class);
     // Fin
     return true;
 }