After I added a new field in the product page, I got a problem to save the content. I got the Content Save Error.
I tried to change some .SS files but still the same error.
What else i should chage?
$fields->addFieldToTab("Root.Content.Main", new TextField("Weight", "Weight (kg)", "", 12));
$fields->addFieldToTab("Root.Content.Main", new TextField("Price", "Price", "", 12));
$fields->addFieldToTab("Root.Content.Main", new TextField("Model", "Author", "", 50));
$fields->addFieldToTab("Root.Content.Main", new TextField("Workshop", "Speaker", "", 50));
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.
E-Commerce Modules /
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Sean, Ed, frankmullenger, biapar, Willr, Ingo, Jedateach, swaiba
How to add a new field to the product.php file?
I would also like to know how to do this.
I've added extra fields, and after doing db/build, I don't get any errors after saving and publishing. However, the new fields won't show up on the product page.
Anyone?
Thanks
Jay
you need to make sure the fields are added in the model as well.
EG:
static $db = array(
'Price' => 'Currency',
'Weight' => 'Decimal(9,2)',
'Model' => 'Varchar',
'FeaturedProduct' => 'Boolean',
'AllowPurchase' => 'Boolean',
"InternalItemID" => "Varchar(30)",
);
That way SilverStripe will know where to save the data.
Hey Bennett, thanks for your reply. I have done this already.. I added the following line to that array.
'Year' => 'Varchar',
And the following line to the getCMSFields function.
$fields->addFieldToTab("Root.Content.Main", new TextField("Year", "Year", "", 50));
I can see the field when I want to create a new product, I can type in the YEAR, I can save it and publish it, but when I go to the product page, "Year" is not displayed.
Do you know why this is happening?
Thank you
Jay!
Hi Jay Dee,
Try (something like) this in your template
<div class="year">
Year: $Year
</div>
$Year will / should display the year data.
:)
Paul