Jump to content


Photo

DefaultDataMaker from other module

DefaultDataMaker other module dropdown Data

  • Please log in to reply
3 replies to this topic

#1 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 08 July 2012 - 02:46 PM

Hello

I am trying to centralize all the list of values that will be used in other modules, this way it's necessary to replicate the data in each module.

For example there is a dropdown called Season that will be applied to multiple model in different modules.

I define in a module called "data" with the following DefaultDataMaker

class DatasDefaultDataMaker extends DefaultDataMaker
{
public function make()
{
  $values = array(
   '000 - No Season',
   '131 - Spring Summer 2013',
   '132 - Fall Winter 2013',
  );
  static::makeCustomFieldDataByValuesAndDefault('Seasons',
			   $values);
}
}

Then in the Materials module the field is defined in the model

'relations' => array(
'season'		   => array(RedBeanModel::HAS_ONE,   'OwnedCustomField', RedBeanModel::NOT_OWNED),
)		
....................
'customFields' => array(
'season'   => 'Seasons',
),		  
 

and in the EditAndDetailsView

array(
'elements' => array(
  array('attributeName' => 'season', 'type'		  => 'DropDown', 'addBlank'	  => true),
),
),			
	

There is no error installing and when in edit mode I even see the field but it's not populated with data, what I am missing?

#2 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 08 July 2012 - 09:52 PM

Did you define in DatasModule the method:


public static function getDefaultDataMakerClassName()
{
return 'DatasDefaultDataMaker';
}

Otherwise it won't get loaded on install.

Jason Green
Zurmo Team
Need support? Upgrade now


#3 k1000o

k1000o

    Advanced Member

  • Members
  • PipPipPip
  • 112 posts
  • LocationMadrid

Posted 09 July 2012 - 06:36 PM

Thanks, I was missing this method, it works now.

#4 Jason

Jason

    Administrator

  • Administrators
  • 864 posts
  • LocationChicago

Posted 11 July 2012 - 11:38 PM

Thanks, I was missing this method, it works now.

Great!

Jason Green
Zurmo Team
Need support? Upgrade now






Also tagged with one or more of these keywords: DefaultDataMaker, other, module, dropdown, Data

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users