Hello all of you.
I got a ProductPage and want to set a claim for the Product. Additionally add some Images and a string('NameofReel') for some jquerymagic. My code/ProductPage looks like this:
<?php
/**
* Defines the Product Page type
*/
class ProductPage extends Page {
static $db = array(
);
static $has_one = array(
"Claim" => "Varchar",
"BigProductImage" => "Image",
"SmallProductImage" => "Image",
"NameofReel" => "Varchar"
);
function getCMSFields() {
$fields = parent::getCMSFields();
$fields->addFieldToTab("Root.Content.Main", new ImageField('BigProductImage','Großes Bild - oben im Produktbild'));
$fields->addFieldToTab("Root.Content.Main", new ImageField('SmallProductImage', 'Kleines Bild - oben im Produktbild'));
$fields->addFieldToTab("Root.Content.Main", new TextField ('Claim','Beschriftung unter dem Produktnamen(Claim)'), 'Content');
$fields->addFieldToTab("Root.Content.Main", new TextField ('NameofReel','Name des Reels (ohne Endung)'), 'Content');
return $fields;
}
}
class ProductPage_Controller extends Page_Controller {
public function init() {
parent::init();
Requirements::block("sapphire/thirdparty/prototype/prototype.js");
Requirements::javascript('themes/sizoobig/js/jquery-1.4.4.min.js');
Requirements::javascript('themes/sizoobig/js/jquery.kwicks-1.5.1.pack.js');
Requirements::javascript('themes/sizoobig/js/jquery.reel.js');
Requirements::javascript('themes/sizoobig/js/globalfunctions.js');
}
}
But the TextField in the cms wont save their strings. The Imagefields work as expected. Whats wrong? I guess its a absolute noob question but I dont see the error?
Thanks for you help. Pipifix
UPDATE:
--------------------------
I#m using SS2.45 and its a multilingual site. So i found this in the translating-docs
class Page extends SiteTree {
public static $db = array(
'AdditionalProperty' => 'Text',
);
function getCMSFields() {
$fields = parent::getCMSFields();
// Add fields as usual
$additionalField = new TextField('AdditionalProperty');
$fields->addFieldToTab('Root.Content.Main', $additionalField);
// If a translation exists, exchange them with
// original/translation field pairs
$translation = $this->getTranslation(Translatable::default_locale());
if($translation && $this->Locale != Translatable::default_locale()) {
$transformation = new Translatable_Transformation($translation);
$fields->replaceField(
'AdditionalProperty',
$transformation->transformFormField($additionalField)
);
}
return $fields;
}
}
I dont know if this causes the saving issue. How to change this code to replace both (NameofReel+Claim) Fields?
This way..?
...
$fields->replaceField(
'NameofReel',
$transformation->transformFormField($reelField)
);
$fields->replaceField(
'Claim',
$transformation->transformFormField($claimField)
);
...
BTW: I've used the alternative way from this docsnippet above to set the textfield
$additionalField = new TextField('AdditionalProperty');
$fields->addFieldToTab('Root.Content.Main', $additionalField);
That doesn't works neither!?