Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Data Model Questions /

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Dynamically create TextField by creating different DataObject


Go to End


980 Views

Avatar
Phils

Community Member, 11 Posts

10 March 2015 at 10:20pm

Hi everyone,

is it possible to create TextFields in one Dataobject by creating a different Dataobject.
The Problem:
I have Product Category pages. Each of them has many Product Features as well as Products.

private static $has_many = array(
	'ProductFeatures' => 'ProductFeature',
  	'Products' => 'Product'
  );

Product Features only have a Title TextField.
Inside my Product DataObject I need a TextField for every Product Feature created.

For Example:
In Silverstripe I create two new Product Features: Name, Price
When opening an existing Product or creating a new one I want these two Features (Name, Price) to appear as TextFields so I can enter their values for this Product.

Is there a way to do this maybe by OnBeforeWrite?

Thanks in advance for every help and sorry about my english.