error = '
Form ID is require, field id is missing in $attrs
'.print_r($attrs, 1).'
';
return;
}
$this->formFields = apply_filters("{$attrs['id']}_fields", $formFields, $attrs);
foreach ($attrs as $name => $value){
$this->$name = $value;
}
}
function div($class = '', $id = ''){
return "";
}
function divClose(){
return "
";
}
function label($label, $for = ''){
return "";
}
function row($id, $fields){
$row = $this->div("form-row", $id);
if(isset($fields['label']))
$this->label($fields['label'], $id);
foreach ($fields['cols'] as $id => $field){
$row .= $this->formGroup($id, $field);
}
$row .= $this->divClose();
return $row;
}
function formGroup($id, $field){
$grid_class = isset($field['grid_class'])?$field['grid_class']:'';
$field_html = $this->div("form-group {$grid_class}", $id);
$type = $field['type'];
$field_html .= $this->div("input-wrapper {$type}-input-wrapper", $id."_wrapper");
if(isset($field['label']))
$field_html .= $this->label($field['label'], $id);
$input = $this->$type($field['attrs']);
if(in_array($type, ['reCaptcha', 'hidden'])) return $input;
$prepend = isset($field['prepend']) ? $field['prepend'] : null;
$append = isset($field['append']) ? $field['append'] : null;
$input = $this->inputGroup($input, $prepend, $append);
$field_html .= $input;
$field_html .= $this->divClose();
$field_html .= $this->divClose();
return $field_html;
}
function inputGroup($input, $prepend = null, $append = null){
if(!$prepend && !$prepend) return $input;
$input_group = "";
return $input_group;
}
function heading($attrs){
$_attrs = "";
$text = $attrs['text'];
unset($attrs['text']);
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
return "{$text}
";
}
function hidden($attrs){
$_attrs = "";
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
$text = "";
return $text;
}
function text($attrs){
$_attrs = "";
$attrs['class'] = isset($attrs['class']) ? "form-control ".$attrs['class']: "form-control";
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
$text = "";
return $text;
}
function email($attrs){
$_attrs = "";
$attrs['class'] = isset($attrs['class']) ? "form-control ".$attrs['class']: "form-control";
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
return "";
}
function password($attrs){
$_attrs = "";
$attrs['class'] = isset($attrs['class']) ? "form-control ".$attrs['class']: "form-control";
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
return "";
}
function select($attrs){
$_attrs = "";
$attrs['class'] = isset($attrs['class']) ? "form-control ".$attrs['class']: "form-control";
$options = $attrs['options'];
unset($attrs['options']);
foreach ($attrs as $key => $value){
$_attrs .= "{$key}='{$value}' ";
}
$_options = "";
foreach ($options as $value => $label){
$_options .= "\r\n";
}
return "";
}
function reCaptcha($attrs){
ob_start();
?>
error) return $this->error;
$form_html = $this->noForm ? "" : "";
return $form_html;
}
}