Flourish PHP Unframework
This is an archived copy of the forum for reference purposes

populate

posted by mungiu 8 years ago

How can i do to use method populate but to not populate one field because i seted the value before.

You can set the value after...

$foo = new Foo();
$foo->populate();
$foo->setValue('value');
$foo->store();
posted by anonymous 8 years ago

this is the problem i need to set before.

posted by mungiu 8 years ago

If you seted the value before populate() but after POST, you can use fRequest::set('field', 'value') to modify this value.

PD. BTW, I can't figure out why you don't set the value after populate and you has to set it before... Can you post some piece of code in order to clarify me?

posted by anonymous 8 years ago

it takes the value from another field and made some changes for friendly url.

posted by mungiu 8 years ago

tank you it's working that way.

posted by mungiu 8 years ago

If you want to make sure the column is always a friendly URL, I would highly recommend adding that functionality to your fActiveRecord class.

class Foo
{
    public function setValue($value)
    {
        return $this->set('value', fURL::makeFriendly($value));
    }
}

This custom ->setValue() method will get called by fActiveRecord::populate().

posted by wbond 8 years ago

can u add a parameter fo chose the separator

posted by mungiu 8 years ago

I presume you are talking about fURL::makeFriendly()?

I've seen some chatter about it on the forum, but no one has submitted a ticket yet. I try to respond to forum posts, but there is no mechanism for me to keep track of what has and hasn't been addressed in the forum. If a ticket is submitted I can keep track of it pretty easily and make sure it either gets fixed, or a reason for it not being fixed is recorded.

posted by wbond 8 years ago

This sounds cool!

Is this feature undocumented? Is there the same functionality for something like getValue()?

posted by xoan 8 years ago

Yes, it is also possible for getting values. fActiveRecord has protected methods ::get() and ::set() that accept a column name, and in the case of ::set(), additionally a value.

From glancing around the documentation it does not appear that it is specifically mentioned anywhere. If you don't mind opening a ticket for it, then I can make sure it gets added. Thanks!

posted by wbond 8 years ago