Forums / Developer / New datatype not storing content

New datatype not storing content

Author Message

Eirik Alfstad Johansen

Tuesday 13 January 2004 5:45:41 am

Hi,

I've created a new datatype, but for some strange reason, it won't store the its value when creating an object. I've done some bug searching by trying to print out the value in the fetchObjectAttributeHTTPInput functionn where the value is supposed to be stored, and the value exists all the way to the following piece of code:

$contentObjectAttribute->setAttribute( "data_text", $data );

...which should save the data. However, just an empty textstring is saved. Does anyone have any idea as to what I could be doing wrong? Thanks in advance !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Hans Melis

Tuesday 13 January 2004 8:19:17 am

Hi Eirik,

Have you implemented the function storeObjectAttribute() in your datatype? Even an empty implementation seems to do the trick according to the eztext datatype, but there are other ways as well.

/*!
Store the content.
*/
function storeObjectAttribute( &$attribute )
{
}

hth

--
Hans

Hans
http://blog.hansmelis.be

Eirik Alfstad Johansen

Tuesday 13 January 2004 10:15:05 am

Hi Hans,

Yes, I have, so that can't be it. Any other ideas?

Thanks in advance !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Eirik Alfstad Johansen

Friday 16 January 2004 6:10:23 am

Hi Hans,

In your previous post you mentioned that "there are other ways as well". What other ways were you referring to, as I still can't get this to work. BTW, here's the mothod which should store the datatype value.

function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
{
if ( $http->hasPostVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" ) ) )
{
$data =& $http->postVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" )
);

$contentObjectAttribute->setAttribute( "data_text", $data );
}

return false;
}

Any insight is greatly appreciated !

Sincerely,

Eirik Johansen

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/

Hans Melis

Friday 16 January 2004 7:45:51 am

Eirik,

The method we usually use in datatypes uses the content(). Example:

function fetchObjectAttributeHTTPInput( &$http, $base, &$contentObjectAttribute )
{
if ( $http->hasPostVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" ) ) )
{
$data =& $http->postVariable( $base . "_data_text_" .
$contentObjectAttribute->attribute( "id" )
);

$contentObjectAttribute->setContent( $data );
return true;
}

return false;
}

and then:

function storeObjectAttribute( &$attribute )
{
$data = $attribute->content();
$attribute->setAttribute('data_text', $date);
}

But I just spotted something. In your fetchHTTPinput function, you don't do a "return true;" when you've done setAttribute(). Maybe that has something to do with it.

--
Hans

Hans
http://blog.hansmelis.be

Eirik Alfstad Johansen

Friday 16 January 2004 10:03:57 am

Hi Hans,

> But I just spotted something. In your fetchHTTPinput function,
> you don't do a "return true;" when you've done setAttribute().
> Maybe that has something to do with it.

That was it! Thanks a million, Hans!

- Eirik

Sincerely,

Eirik Alfstad Johansen
http://www.netmaking.no/