MAR

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?

Todd


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

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):

function __get($key){
	if( method_exists( $this, $key ) ){
		return call_user_func( array($this, $key) );
	}else{
		return isset($this->$key) ? $this->$key : false;
	}
}

Walter

On Feb 20, 2009, at 2:25 PM, Todd wrote:

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?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Take a look at the current case ‘index’:

http://pastie.org/395598

Do I need to change $item to $person?

T.

On Feb 20, 2009, at 3:10 PM, Walter Lee Davis wrote:

Now simply call $person->full_name() in place of $person->name.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Yup. http://pastie.org/395611

And http://pastie.org/395612

Walter

On Feb 20, 2009, at 5:25 PM, Todd wrote:

Take a look at the current case ‘index’:

http://pastie.org/395598

Do I need to change $item to $person?

T.

On Feb 20, 2009, at 3:10 PM, Walter Lee Davis wrote:

Now simply call $person->full_name() in place of $person->name.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options