Hi,
I’m stumped on this one… hope I’m not being daft.
This custom field works exactly as I expect it should. It displays a textarea, I insert some HTML and text, save it, no worries.
class Test_field_ft extends EE_Fieldtype {
var $info = array(
'name' => 'Test Field',
'version' => '1.0'
);
function Test_field_ft()
{
parent::EE_Fieldtype();
}
// --------------------------------------------------------------------
function display_field($data)
{
return form_textarea(array(
'name' => $this->field_name,
'id' => $this->field_id,
'value' => $data
));
}
function save($data)
{
return $data;
}
}However I would like some array type fields like “field_id_7[content]”:
class Test_field_ft extends EE_Fieldtype {
var $info = array(
'name' => 'Test Field',
'version' => '1.0'
);
function Test_field_ft()
{
parent::EE_Fieldtype();
}
// --------------------------------------------------------------------
function display_field($data)
{
return form_textarea(array(
'name' => $this->field_name."[content]",
'id' => $this->field_id,
'value' => $data
));
}
function save($data)
{
return $data['content'];
}
}Now when I save my data
and go back to the publish page it has been converted to entities
&<p></p>Am I missing something blatant? Any help would be appreciated as its killing me 😛
Update: I’m working around this with “html_entity_decode”… though I don’t think this is the right route to take.
function display_field($data)
{
return form_textarea(array(
'name' => $this->field_name."[content]",
'id' => $this->field_id,
'value' => html_entity_decode($data)
));
}Thanks, I’ll give base64 a shot to see how that works but I don’t think it’s going to be an ideal solution for this instance because it won’t be searcheable in mysql… hrmmm.
Html-decoding the entities has been working out for me so far (at least no corrupt data yet) until I tried the feature where autosaved data is reloaded to the publish page… BAAAP (annoying buzzer sound) - all the data was reloaded but as entities.
@ender: Glad I’m not the only one.
@DevDemon: Good question, the original characters are retained (ie. not as entities).
Just as they’re reloaded into the publish page they get turned into entities (I spent a lot of time pouring over EE core to figure this out but couldn’t come up with anything). It’s especially painful when working with serialized arrays as it corrupts the whole array (quotes get turned to & quote ; etc).
Anywho. I didn’t have any time to look at this today (Monday madness here), maybe I’ll get back to the fieldtype groove this weekend.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.