Instead of collecting first and last names as one variable
<?=h($name)?>
they’re now separate,
<?=h($first)?>
<?=h($last)?>
So far so good.
In the controller, the if statement:
case 'edit':
if(isset($_POST['name'])){
$mar->populate(clean($_POST));
$mar->save();
$mar->manage_result('_flash','flash','<b class="success">Changes
successfully saved.</b>',$self);
}
obviously would not allow me to update entries because it was using
the old variable ‘name’ so I changed it to ‘first’ which works but
somehow that doesn’t seem right. Shouldn’t it need the first and last
names?
[Now for the embarrassing question] To adjust for the two variables in:
case 'index':
I added
$item->s('first') . $item->s('last')
which works fine, but how do I get a space to render between the names?
Try adding a dummy hidden field to your form, <input type="hidden" name="sent" /> and then look for $_POST['sent'] in your controller.
Another way around this is to give your submit button a name attribute.
For the name, what I would do is add a method to your model:
class people extends ActiveRecord {
function full_name(){
$out[] = $this->first;
$out[] = $this->last;
return trim(implode(' ', $out));
}
}
Now simply call $person->full_name() in place of $person->name.
If you add the following function to your ActiveRecord class, you can
get away with $person->full_name (as long as there isn’t any real
field named that, of course):
obviously would not allow me to update entries because it was using
the old variable ‘name’ so I changed it to ‘first’ which works but
somehow that doesn’t seem right. Shouldn’t it need the first and
last names?
[Now for the embarrassing question] To adjust for the two variables
in:
case 'index':
I added
$item->s('first') . $item->s('last')
which works fine, but how do I get a space to render between the
names?