class -> array undefined index PHP -
- this unsolved
i have class i've put crud me. here sections applicable issue.
i returning 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. need include "leadstage" * in being created, date created, * time created, , user 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 input our new stage. $element = $this->addinputerror_new_element($option); } elseif($option['formfield'] = 'status') { // build our markup selecting our status. $element = $this->addselecterror_new_element($option); } return $element; } function makeentireform() { // next stage forget hard coding instead pass in array of elments want made , 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 not use. hit cancel , 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 array values , looks spot on? can maybe second set of eyes on , see think?
let me know if need explanation or need see functions not listed.
errors populating 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 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 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; // have echo ($output); in 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 1 --</option> '.makeoptions($selectarray, $value).' </select>' . '</div>' . '</div>'; return $output; // have echo ($output); in html file }
i meant (sorry if did not understand comments)
class leadstage { private $my_object; function __construct() { $this->my_object = new formfields(); } // input field -> stage function addinputerror_new_element($option) { //$formfields = new formfields(); $element = $this->my_object->inputerror_new( //............... //................. similarly everywhere same. point variable use $this keyword should have variable in class.
Comments
Post a Comment