本文整理匯總了PHP中CompositeField::Create方法的典型用法代碼示例。如果您正苦於以下問題:PHP CompositeField::Create方法的具體用法?PHP CompositeField::Create怎麽用?PHP CompositeField::Create使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類CompositeField
的用法示例。
在下文中一共展示了CompositeField::Create方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __construct
public function __construct($controller, $name)
{
$starRatingCats = $this->stat('star_rating_categories');
$maxStars = $this->stat('max_stars');
$fields = FieldList::create($starRatingFields = CompositeField::Create(), TextField::create('Title', '')->setAttribute('placeholder', 'Title')->setAttribute('required', 'true'), TextareaField::create('Comments', '')->setAttribute('placeholder', 'Comments')->setAttribute('required', 'true'), HiddenField::create('MaxRating')->setValue($maxStars));
if ($starRatingCats) {
foreach ($starRatingCats as $cat => $catName) {
$starRatingFields->push(NumericField::create('StarRating[' . $catName . ']', $catName)->setAttribute('type', 'number')->setAttribute('data-max', $maxStars)->setAttribute('data-min', '1')->addExtraClass('rating'));
}
}
$actions = FieldList::create(FormAction::create('process', 'Submit')->addExtraClass('btn btn-primary'));
parent::__construct($controller, $name, $fields, $actions);
$this->setHTMLID('product-review-form');
$this->disableSecurityToken();
}