I have 2 questions
<< 1.>>
I have php print code like this.
echo '<label class="control-label" for="'.to_string($dt->name_comp).'">'.$dt->name_comp.'</label>';
to_string is function that produce My Name to my_name, and it works, clear, with $dt->name_comp produce the value from database.
So.. that syntax must be html syntax like it: <label class="control-label" for="my_name">Name Component</label>
I wanna ask, why code above can't work? Why my_name not get into for?
I've tried this way:
echo '<label class="control-label" for="'. <?php to_string($dt->name_comp); ?>.'">'.$dt->name_comp.'</label>';
But, it same. The result is always like this: <label class="control-label" for=" ">Name Component</label>
when I check it in firebug. So my_name appear outside form, doesn't enter into the form. Wonder why..
This is to_string()
function:
function to_string($string) {
$string = preg_replace('/[\'"]/', '', $string);
$string = preg_replace('/[^a-zA-Z0-9]+/', '_', $string);
$string = trim($string, '_');
$string = strtolower($string);
echo $string;
}
<< 2>>
I have code for textinput like this:
echo '<input type="text" name="'.to_string($dt->name_comp).'" id="'.to_string($dt->name_comp).'" placeholder="'.$dt->name_comp.'" value="'.$dt['/name_comp/'].'">';
But, there is an error: Fatal error cannot use object of type workspace_mockup_2\Models\Component as array What should I enter there? Need some advice.. Thank's.