Jump to content


Photo

Using more than one custom field in a module

custom field module owned

  • Please log in to reply
1 reply to this topic

#1 xxxDKPROxxx

xxxDKPROxxx

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 18 August 2015 - 03:14 PM

I have currently set up a module of my own based off the Animals module, I have 5 custom fields all of which are drop downs and 4 of these 5 call the same custom pick list. When updating the schema the database correctly creates 5 different fields for the customfield_id e.g. artist_grade_conf_customfield_id. However when I save the Artist none of these 5 fields are saved but the customfield_id field keeps the final value that was written.

 

Then when you load the saved Artist all the drop downs use the same picklist (even the 5th one that uses a different picklist) and the value is that of the customfield_id so they are all the same!

 

I cannot seem to work this out, please help!



#2 xxxDKPROxxx

xxxDKPROxxx

    Newbie

  • Members
  • Pip
  • 4 posts

Posted 19 August 2015 - 11:28 AM

Afternoon all,

 

Just a quick heads up, I have managed to fix this and the issue is replicated in the standard Animals module of ZurmoZoo!

 

I was using multiple custom fields in my new module however when declaring the relations I was not declaring 

RedBeanModel::LINK_TYPE_SPECIFIC,

So in the database it was entering every custom field into the customfield_id column meaning that it only ever had one value which in turn set every dropdown in the custom fields array to that value no matter what type of custom field was declared.

 

Here is an example of a well-formed custom field declaration;

'relations' => array(

'contact_type' => array(RedBeanModel::HAS_ONE, 'OwnedCustomField', 
RedBeanModel::OWNED, RedBeanModel::LINK_TYPE_SPECIFIC, 'contact_type'),

'artist_type' => array(RedBeanModel::HAS_ONE, 'OwnedCustomField', 
RedBeanModel::OWNED, RedBeanModel::LINK_TYPE_SPECIFIC, 'artist_type'),

'contact' => array(RedBeanModel::HAS_ONE, 'Contact'),
),






Also tagged with one or more of these keywords: custom, field, module, owned

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users