We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

3.1.0 DP 5 Field Type Errors

Developer Preview

TJ Draper's avatar
TJ Draper
222 posts
9 years ago
TJ Draper's avatar TJ Draper

I sort of hate to be reporting errors for DP 5 when I know DP 6 is supposed to be out the door and may fix these, but I’m trying to get some work done on my add-on to be ready for the 3.1.0 release. I’m running into some errors with field type development at the moment.

First up, when I create a field from my field type, then go back to edit it, I am presented with the lovely error screen I have attached.

The second thing I’m running into is that the display_field method is not being run at all on my field type and a text input field is being displayed. See attached images.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
9 years ago
Kevin Cupp's avatar Kevin Cupp

Interesting, looks like it might be having trouble instantiating the field type class. If you look in your exp_channel_fields table, does that field have the right value for its field_type column? Should be whatever you name the add-on file, ft.x.php. And is this name different than the other files in your package? Like, does your add-on have multiple fieldtypes in it?

Also, if we could have a full stack trace for one of those errors, that might help us, too.

       
TJ Draper's avatar
TJ Draper
222 posts
9 years ago
TJ Draper's avatar TJ Draper

The field types in the database are correct. My add-on has two field types which I am declaring in addon.setup per the new docs:

'fieldtypes' => array(
 'construct' => array(
  'name' => 'Construct',
  'compatibility' => 'construct'
 ),
 'construct_node_chooser' => array(
  'name' => 'Construct Node Chooser',
  'compatibility' => 'construct_node_chooser'
 )
)

I’m still playing with the compatibility thing. I don’t know what that does and does not do. They aren’t really compatible with anything else so I set them to the name of the field-type. I also tried various values listed in the docs to see if that was causing a problem, no dice.

The top field type has been in the add-on since the EE 2.x days and has the same name as the add-on package. The other field-type is new. But the error is happening with both of them.

There is no strack trace, only E_WARNING, E_NOTICE, E_RECOVERABLE_ERROR etc.

       
TJ Draper's avatar
TJ Draper
222 posts
9 years ago
TJ Draper's avatar TJ Draper

I did one additional test, I removed my new field type, removed the fieldtypes from the add-on.setup, and put everything back the way it was when the field type was working on previous developer previews. It still throws the error when trying to edit the field and shows only a text input field on the publish page — not loading the display_field method at all. I had finished the main field type with DP 4 (I think it was) and it was working then.

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
9 years ago
Kevin Cupp's avatar Kevin Cupp

Change your save_settings() method to something like this and save the field:

public function save_settings($data)
{
    // Make the field take up the full width of the publish page
    return array('field_wide' => TRUE);
}

Should fix it. No need to send back the entire $data array, it’s basically just POST and there so it’s easy to pluck things out of. That way you’re also not storing the entire contents of POST into your field_settings column, too.

       
TJ Draper's avatar
TJ Draper
222 posts
9 years ago
TJ Draper's avatar TJ Draper

Okay, that’s interesting. Out of curiosity, why would it have worked initially then stopped working?

       
Kevin Cupp's avatar
Kevin Cupp
791 posts
9 years ago
Kevin Cupp's avatar Kevin Cupp

Not sure exactly what changed, but a series of array merges was causing the field_id to be overwritten by the empty one stored in your field settings column. I think we’re going to build in some protection for that.

       

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.