- THIS IS UNSOLVED
I have a class that I've put together to do a CRUD for me. Here is the sections that are applicable to my issue.
I am returning the following errors.
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: placeholder in class/LeadStages.php on line 88
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: id in class/LeadStages.php on line 90
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: type in class/LeadStages.php on line 91
[07-Apr-2017 15:45:40 America/Los_Angeles] PHP Notice: Undefined index: maxchar in class/LeadStages.php on line 93
Class
class LeadStage {
/*
* Create LeadStage. You will need to include the "LeadStage"
* in which is being created, the date created,
* time created, and the user who created it.
*/
function __construct() {
$this->FormFields = new FormFields;
}
// Input Field -> Stage
function addInputError_New_Element($option) {
var_dump($option);
$element = $this->FormFields->InputError_NEW(
$Error = $option['error'],
$Value = $option['value'],
$PlaceHolder = $option['placeholder'],
$InputName = $option['name'],
$InputID = $option['id'],
$InputType = $option['type'],
$InputLabel = $option['label'],
$MaxChar = $option['maxchar'],
$required = $option['required']
);
return $element;
}
// Select Option -> Status
function addSelectError_New_Element($option) {
$element = $this->FormFields->SelectError_NEW(
$ErrorMSG = $options['error'],
$InputLabel = $option['label'],
$Class = $option['class'],
$DataTargetDIVID = $option['targetid'],
$SelectName = $option['name'],
$SelectArray = $option['array'],
$Value = $option['value'],
$required = $option['required'],
$Value = FALSE
);
return $element;
}
function addElementToForm($option) {
if($option['FormField'] = 'stage') {
// Build our Markup to input our new stage.
$element = $this->addInputError_New_Element($option);
}
elseif($option['FormField'] = 'status') {
// Build our Markup for selecting our status.
$element = $this->addSelectError_New_Element($option);
}
return $element;
}
function makeEntireForm() { // next stage is to forget hard coding instead pass in array of elments you want made and cycle through array.
/*
* Create Input field -> Stage
*/
$entireForm = '';
$option = array(
'FormField' => 'stage',
'error' => FALSE,
'value' => FALSE,
'placeholder' => 'Stage (ie; Scheduled Inspection)',
'name' => 'stage',
'id' => FALSE,
'type' => 'text',
'label' => 'Stage',
'maxchar' => 50,
'required' => TRUE
);
// Build Element
$entireForm .= $this->addElementToForm($option);
/*
* Create Input field -> Status
*/
$arrayvalues = array('Test','Test2');
$option = array(
'FormField' => 'status',
'error' => FALSE,
'label' => 'Status',
'class' => FALSE,
'targetid' => FALSE,
'name' => 'status',
'array' => $arrayvalues,
'value' => FALSE,
'required' => TRUE
);
// Build Element
$entireForm .= $this->addElementToForm($option);
return $entireForm;
}
function viewLeadStagesMarkup($title,$action,$return) {
$Form = $this->makeEntireForm();
$HTML____ = NULL;
$HTML____ .= '<form class="form-horizontal" action="'. $action .'" method="post">' .
'<div class="panel panel-info">' .
'<div class="panel-heading">' .
'<h3 class="panel-title">'. $title .'</h3>' .
'</div>' .
'<div class="panel-body">' .
'<p>WARNING: Page under maintenance. Please do not use. Hit cancel and go back.</p>' .
'<div class="row">' .
'<div class="col-md-12 col-lg-12">' .
$Form .
'</div>' .
'</div>' .
'</div>' .
'<div class="panel-footer">' .
'<a href="'.$return.'" type="button" class="btn btn-sm btn-warning"><i class="#"></i>Cancel</a> ' .
'<div class="pull-right">' .
'<button type="submit" class="btn btn-sm btn-success">Create</button>' .
'</div>' .
'</div>' .
'</div>' .
'</form>';
return $HTML____;
}
}
I have double checked my array values and everything looks spot on? Can someone maybe get a second set of eyes on it and see what they think?
Let me know if you need explanation or need to see any functions that are not listed.
errors are populating from code section
// Input Field -> Stage
function addInputError_New_Element($option) {
var_dump($option);
$element = $this->FormFields->InputError_NEW(
$Error = $option['error'],
$Value = $option['value'],
$PlaceHolder = $option['placeholder'],
$InputName = $option['name'],
$InputID = $option['id'],
$InputType = $option['type'],
$InputLabel = $option['label'],
$MaxChar = $option['maxchar'],
$required = $option['required']
);
return $element;
}
result from var_dump($option);
array(10) { ["FormField"]=> string(5) "stage" ["error"]=> bool(false) ["value"]=> bool(false) ["placeholder"]=> string(31) "Stage (ie; Scheduled Inspection" ["name"]=> string(5) "stage" ["id"]=> bool(false) ["type"]=> string(4) "text" ["label"]=> string(5) "Stage" ["maxchar"]=> int(50) ["required"]=> bool(true) } array(9) { ["FormField"]=> string(5) "stage" ["error"]=> bool(false) ["label"]=> string(6) "Status" ["class"]=> bool(false) ["targetid"]=> bool(false) ["name"]=> string(6) "status" ["array"]=> array(2) { [0]=> string(4) "Test" [1]=> string(5) "Test2" } ["value"]=> bool(false) ["required"]=> bool(true) }
FormFields Class Functions i am using.
function InputError_NEW($Error, $Value, $PlaceHolder, $InputName, $InputID, $InputType, $InputLabel, $MaxChar,$required) {
$output = '<div class="control-group">';
if (!empty($Error)) {
$output .='<label class="control-label" for="inputError">
<i style="color:red" class="fa fa-times-circle-o">
<b>'.$Error.'</b>
</i>
</label>';
}
$output .='<label class="control-label">' . $InputLabel . '</label>' .
'<div class="controls">' .
'<input class="form-control"';
if (!empty($InputID)) {
$output .= ' id="' . $InputID . '"';
}
if (!empty($InputName)) {
$output .= ' name="' . $InputName . '"';
}
if (!empty($InputType)) {
$output .= ' type="' . $InputType . '"';
}
if (!empty($PlaceHolder)) {
$output .= ' placeholder="' . $PlaceHolder . '"';
}
if (!empty($Value)) {
$output .= ' value="' . $Value . '"';
}
if (!empty($MaxChar)) {
$output .=' maxlength="'. $MaxChar . '"';
}
if ($required) {
$output .= ' required';
}
$output .= '>' .
'</div>' .
'</div>';
return $output; // you will have to echo ($output); in the HTML file
}
function SelectError_NEW($Error, $InputLabel, $Class, $DataTargetDIVID, $SelectName, $SelectArray, $Value) {
$output = '<div class="control-group">';
if (!empty($Error)) {
$output .='<label class="control-label" for="inputError">
<i style="color:red" class="fa fa-times-circle-o">
<b>'.$Error.'</b>
</i>
</label>';
}
$output .='<label class="control-label">' . $InputLabel . '</label>' .
'<div class="controls">' .
'<select class="form-control ' . $Class . '" data-target="' . $DataTargetDIVID .'" name="' . $SelectName .'"';
if ($required) {
$output .= ' required';
}
$output .='>
<option value="">-- Select One --</option>
'.makeOptions($SelectArray, $Value).'
</select>' .
'</div>' .
'</div>';
return $output; // you will have to echo ($output); in the HTML file
}
var_dump($option)__construct(). you should update your question thenPHP Fatal error: Call to undefined function FormFields()