/**
  * JsonFormBuilder_elementRadioGroup
  * 
  * Creates a group of radio button elements.
  * 
  * <code>
  * $a_performanceOptions = array(
  *	'opt1'=>'Poor',
  *	'opt2'=>'Needs Improvement',
  *	'opt3'=>'Average',
  *	'opt4'=>'Good',
  *	'opt5'=>'Excellent'
  * );
  * $o_fe_staff = new JsonFormBuilder_elementRadioGroup('staff_performance','How would you rate staff performance?',$a_performanceOptions,'opt3');
  * </code>
  *
  * @param string $id The ID of the element
  * @param string $label The label of the select element
  * @param array $values An array of title/value arrays in order of display
  * @param string $defaultValue The value of the default selected radio option
  */
 function __construct($id, $label, array $values, $defaultValue = null)
 {
     parent::__construct($id, $label);
     $this->_showIndividualLabels = true;
     $this->setValues($values);
     $this->setDefaultVal($defaultValue);
 }
 /**
  * JsonFormBuilder_elementCheckbox
  * 
  * Creates a checkbox form element.
  *
  * @param string $id ID of checkbox
  * @param string $label Label of checkbox
  * @param string $value Value to show if user selects the checkbox
  * @param boolean $uncheckedValue Value to show if user does not check the checkbox
  * @param mixed $checked The checkbox will be checked by default if true is supplied OR if the checked value is supplied. e.g. if checked value is "Agree" and this parameter is set to "Agree" the checkbox will be checked by default.
  */
 function __construct($id, $label, $value = 'Checked', $uncheckedValue = 'Unchecked', $checked = false)
 {
     parent::__construct($id, $label);
     $this->setValue($value);
     $this->setChecked($checked);
     $this->setUncheckedValue($uncheckedValue);
     $this->_labelAfterElement = true;
 }
 /**
  * JsonFormBuilder_elementCheckboxGroup
  * 
  * Creates a group of checkboxes that allow rules such as required, minimum length (minimum number of items that must be checked) and maximum length (maximum number of items that can be checked). The list of checkbox values are specified in an array along with their default ticked state.
  * 
  * <code>
  * $a_checkArray=array(
  *	array('title'=>'Cheese','checked'=>false),
  *	array('title'=>'Grapes','checked'=>true),
  *	array('title'=>'Salad','checked'=>false),
  *	array('title'=>'Bread','checked'=>true)
  * );
  * $o_fe_checkgroup		= new JsonFormBuilder_elementCheckboxGroup('favFoods','Favorite Foods',$a_checkArray);
  * //Ensure at least 2 checkboxes are selected
  * $a_formRules[] = new FormRule(FormRuleType::minimumLength,$o_fe_checkgroup,2);
  * //Ensure no more than 3 checkboxes are selected
  * $a_formRules[] = new FormRule(FormRuleType::maximumLength,$o_fe_checkgroup,3);
  * </code>
  *
  * @param string $id Id of the element
  * @param string $label Label of the select element
  * @param array $values Array of title/value arrays in order of display.
  */
 function __construct($id, $label, array $values)
 {
     parent::__construct($id, $label);
     $this->_name = $id . '[]';
     $this->_values = $values;
     $this->_showIndividualLabels = true;
     $this->_uncheckedValue = 'None Selected';
 }
 /**
  * JsonFormBuilder_elementDate
  * 
  * Creates three combined form elements to allow users to enter a date using three dropdown lists.
  *
  * @param type $id The id of the field (three modified ids that add _day, _month, _year to the end of this id will result.
  * @param type $label The label of the data element.
  * @param type $year_start The start year to show in the year dropdown (default=current year - 90).
  * @param type $year_end  Then end year to show in dropdown (default=current year + 10).
  * @param type $defaultValue Pass in a unix timestamp to set a default date.
  */
 function __construct($id, $label, $format = 'dd/mm/yyyy', $year_start = NULL, $year_end = NULL, $defaultValue = NULL)
 {
     parent::__construct($id, $label);
     $this->setDateFormat($format);
     $this->setYearStart($year_start);
     $this->setYearEnd($year_end);
     $this->_defaultVal0 = date('jS', $defaultValue);
     $this->_defaultVal1 = date('F', $defaultValue);
     $this->_defaultVal2 = date('Y', $defaultValue);
 }
 /**
  * JsonFormBuilder_elementText
  * 
  * Creates a text field.
  * @param string $id The ID of the text field
  * @param string $label The label of the text field
  * @param string $defaultValue The default text to be written into the text field
  */
 function __construct($id, $label, $defaultValue = NULL)
 {
     parent::__construct($id, $label);
     $this->_defaultVal = $defaultValue;
     $this->_maxLength = NULL;
     $this->_minLength = NULL;
     $this->_maxValue = NULL;
     $this->_minValue = NULL;
     $this->_fieldType = 'text';
 }
 /**
  * JsonFormBuilder_elementTextArea
  * 
  * Creates a text area element.
  * @param string $id ID of text area
  * @param string $label The label of text area
  * @param int $rows The required rows (attribute value that must be set on a valid XHTML textarea tag)
  * @param int $cols The required cols (attribute value that must be set on a valid XHTML textarea tag)
  * @param string $defaultValue The default text to be written into the text area
  */
 function __construct($id, $label, $rows = NULL, $cols = NULL, $defaultValue = NULL)
 {
     parent::__construct($id, $label);
     $this->setDefaultVal($defaultValue);
     if (!empty($rows)) {
         $this->setRows($rows);
     }
     if (!empty($cols)) {
         $this->setColumns($cols);
     }
 }
 function __construct($id, $label, $type, $rowLabels, $columnLabels)
 {
     parent::__construct($id, $label);
     if ($columnLabels) {
         $this->setColumns($columnLabels);
     }
     if ($rowLabels) {
         $this->setRows($rowLabels);
     }
     if ($type) {
         $this->setType($type);
     }
 }
 /**
  * JsonFormBuilder_elementButton
  * 
  * Creates a form button element
  *
  * @param string $id The ID of the button
  * @param string $buttonLabel The label of the button
  * @param string $type The button type, e.g button, image, reset, submit etc.
  */
 function __construct($id, $buttonLabel, $type = null)
 {
     parent::__construct($id, $buttonLabel);
     $this->_showLabel = false;
     $this->_showInEmail = false;
     /*
     		if($type=='button' || $type=='image' || $type=='reset' || $type=='submit'){
     			//ok -- valid type
     		}else{
     			JsonFormBuilder::throwError('[Element: '.$this->_id.'] Button "'.htmlspecialchars($type).'" must be of type "button", "reset", "image" or "submit"');
     		}
     */
     $this->_type = $type;
 }
 /**
  * JsonFormBuilder_elementSelect
  * 
  * Creates a select dropdown element.
  *
  * <code>
  * $a_usstates = array(
  *	''=>'Please select...',
  *	'AL'=>'Alabama',
  *	'AK'=>'Alaska',
  *	'AZ'=>'Arizona',
  *	'AR'=>'Arkansas',
  *	'CA'=>'California',
  *	'CO'=>'Colorado',
  *	'CT'=>'Connecticut'
  * );
  * $o_fe_usstates = new JsonFormBuilder_elementSelect('ussuate','Select a state',$a_usstates,'AR');
  * </code>
  * 
  * @param string $id The ID of the element
  * @param string $label The label of the select element
  * @param array $values An array of title/value arrays in order of display
  * @param string $defaultValue The default value to select in the dropdown field 
  */
 function __construct($id, $label, $values = null, $defaultValue = null)
 {
     parent::__construct($id, $label);
     $this->setValues($values);
     $this->setDefaultVal($defaultValue);
 }
 /**
  * JsonFormBuilder_elementReCaptcha
  * 
  * Constructor for the JsonFormBuilder_elementReCaptcha object.
  * @param string $label 
  */
 function __construct($label)
 {
     parent::__construct('recaptcha', $label);
     $this->_showInEmail = false;
 }